Interface Prisoner


public interface Prisoner

Interface Prisoner should be implemented by strategies. There are three methods to implement that together constitute a strategy.


Field Summary
static int THREE_PLAYER_MAJORITY
          Three-player game with "majority" rules.
static int THREE_PLAYER_MINORITY
          Three player game with "minority" rules.
static int TWO_PLAYER
          This constant indicates that this is a two-player game.
 
Method Summary
 void gameResults(int[] playerIDs, int[] playerActions, int myGameScore, int myTotalScore)
          Method gameResults is called by the simulator to inform you of the results of the previous game.
 int playGame(int gameType, int[][] valueMatrix, int[] playerIDs)
          Method playGame is where you apply your strategy.
 void setID(int ID)
          Method setID is called by the simulator to give you an ID.
 

Field Detail

TWO_PLAYER

public static final int TWO_PLAYER
This constant indicates that this is a two-player game.

See Also:
Constant Field Values

THREE_PLAYER_MAJORITY

public static final int THREE_PLAYER_MAJORITY
Three-player game with "majority" rules.

See Also:
Constant Field Values

THREE_PLAYER_MINORITY

public static final int THREE_PLAYER_MINORITY
Three player game with "minority" rules.

See Also:
Constant Field Values
Method Detail

setID

public void setID(int ID)
Method setID is called by the simulator to give you an ID. In this method, simply store the the ID given to you as the parameter.

Parameters:
ID - an int value

playGame

public int playGame(int gameType,
                    int[][] valueMatrix,
                    int[] playerIDs)
Method playGame is where you apply your strategy. You are given the type of game (one of the int constants above), the payoff matrix as the second parameter, the player ID's in an array. The number of player ID's depends on the "size"of the game. For a 2-player game, this will have two entries (one of which will be your ID). For a 3-player game, this will have three entries (one of which will be your ID). The playerID array simply tells you who you are playing against. You are to return your "move" as the int return value. For the Prisoner's Dilemma, there are only two moves possible (in all three types of Prisoner games): you can either cooperate or betray.

Parameters:
gameType - an int value
valueMatrix - an int[][] value
playerIDs - an int[] value
Returns:
an int value

gameResults

public void gameResults(int[] playerIDs,
                        int[] playerActions,
                        int myGameScore,
                        int myTotalScore)
Method gameResults is called by the simulator to inform you of the results of the previous game. Thus, playGame() is first called, during which you compute your "move" and return it. The simulator applies your move (as well as the moves of the other player(s)) and then computes the payoffs. These values are returned to you via the gameResults method so that you can store a history of interaction with other players. The first array is a list of playerID's (including yours). The second is a list of actions taken by the players (including your action). The third is what you scored on this game, and the fourth is your total score so far.

Parameters:
playerIDs - an int[] value
playerActions - an int[] value
myGameScore - an int value
myTotalScore - an int value