|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 |
public static final int TWO_PLAYER
public static final int THREE_PLAYER_MAJORITY
public static final int THREE_PLAYER_MINORITY
Method Detail |
public void setID(int ID)
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.
ID
- an int
valuepublic int playGame(int gameType, int[][] valueMatrix, int[] playerIDs)
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.
gameType
- an int
valuevalueMatrix
- an int[][]
valueplayerIDs
- an int[]
value
int
valuepublic void gameResults(int[] playerIDs, int[] playerActions, int myGameScore, int myTotalScore)
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.
playerIDs
- an int[]
valueplayerActions
- an int[]
valuemyGameScore
- an int
valuemyTotalScore
- an int
value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |