|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectipdlx.Game
public abstract class Game
Base class for all games
| Field Summary | |
|---|---|
protected boolean |
broadcastResult
|
protected boolean |
broadcastRoundResults
|
protected java.util.Vector |
gameListeners
|
protected GameMatrix |
gameMatrix
payoff matrix of the game |
protected GameResult |
gameResult
info about the result of this game |
protected long |
moveTimeLimit
|
protected java.util.Vector |
players
all players |
protected float |
probabilityOfMistake
The percentage of mistakes the strategy makes. |
protected float |
stDev
how many rounds (iterations) |
| Fields inherited from interface ipdlx.PDValues |
|---|
COOPERATE, DEFAULT_MISTAKE_LEVEL, DEFAULT_PUNISHMENT, DEFAULT_REWARD, DEFAULT_SUCKER, DEFAULT_TEMPTATION, DEFECT, EXIT, moves, PLAYER_A, PLAYER_B |
| Constructor Summary | |
|---|---|
Game(Game game)
Constructs a new game with the same game parameters as the given one. |
|
Game(int nrOfRounds,
GameMatrix gameMatrix)
constructor |
|
Game(int nrOfRounds,
GameMatrix gameMatrix,
float noise)
constructor |
|
| Method Summary | |
|---|---|
void |
addGameListener(GameListener gameListener)
|
void |
addPlayer(Player player)
Adds a player to this game instance. |
void |
addPlayers(java.util.Vector players)
Adds an array of players to this game instance. |
protected void |
broadcastGameStart(Game game)
|
protected void |
broadcastResults(GameResult result)
|
protected void |
broadcastRoundResults(GameRoundResult result)
|
double |
filterMove(double move)
Returns a possibly modified move from another. |
boolean |
getBroadcastResult()
|
boolean |
getBroadcastRoundResults()
|
java.util.Vector |
getGameListeners()
|
GameMatrix |
getGameMatrix()
Returns the game matrix. |
float |
getNrRoundsStDev()
Returns the standard deviation set for the number of rounds to play. |
int |
getNumberOfRounds()
Returns the currently set number of rounds. |
int |
getNumberOfRounds(boolean useStDev)
Returns the current number of rounds. |
int |
getNumberOfRoundsStDev()
Returns a deviation of the current number of rounds and current standard deviation setting. |
float |
getProbabilityOfMistake()
Returns the probability of mistake setting for all moves in the current game state. |
protected double |
getStrategyMove(Strategy strategy)
Returns the move from a given strategy. |
protected double |
getStrategyMove(Strategy strategy,
boolean checkTimeLimit)
Returns the move from a given strategy. |
GameResult |
play()
plays the game and return the results of it |
void |
removeGameListener(GameListener gameListener)
|
void |
setBroadcastResult(boolean broadcast)
|
void |
setBroadcastRoundResults(boolean broadcast)
|
void |
setGameMatrix(GameMatrix gameMatrix)
Sets the game matrix. |
void |
setMoveTimeLimit(long timeLimitMillis)
Sets the time limit for a player move at each iteration. |
void |
setNrRoundsStDev(float stDev)
Sets the standard deviation for the number of rounds to play. |
void |
setNumberOfRounds(int nrOfRounds)
Sets the number of rounds to play |
void |
setPlayers(java.util.Vector players)
Sets the players to play this game. |
void |
setProbabilityOfMistake(float probabilityOfMistake)
|
java.lang.String |
toString()
Returns a small description of the current game parameters |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected long moveTimeLimit
protected float stDev
protected java.util.Vector players
protected GameResult gameResult
protected GameMatrix gameMatrix
protected float probabilityOfMistake
protected java.util.Vector gameListeners
protected boolean broadcastResult
protected boolean broadcastRoundResults
| Constructor Detail |
|---|
public Game(Game game)
game - a template game to copy parameters from
public Game(int nrOfRounds,
GameMatrix gameMatrix)
nrOfRounds - number of iterationsgameMatrix - matrix of the prisoner's dilemma game
public Game(int nrOfRounds,
GameMatrix gameMatrix,
float noise)
nrOfRounds - number of iterationsgameMatrix - matrix of the prisoner's dilemma gamenoise - probability of mistake| Method Detail |
|---|
public java.lang.String toString()
toString in class java.lang.Objectpublic final void setNumberOfRounds(int nrOfRounds)
nrOfRounds - number of iterations to playpublic final int getNumberOfRoundsStDev()
public final int getNumberOfRounds(boolean useStDev)
useStDev - if true returns a deviation from the currently set number of
rounds to play.public final int getNumberOfRounds()
public final GameMatrix getGameMatrix()
public void addPlayer(Player player)
player - the player to add.public void addPlayers(java.util.Vector players)
players - the players to add.public final void setNrRoundsStDev(float stDev)
stDev - the standard deviationpublic final float getNrRoundsStDev()
public void setPlayers(java.util.Vector players)
players - the playerspublic void setGameMatrix(GameMatrix gameMatrix)
gameMatrix - the game matrix.public void setMoveTimeLimit(long timeLimitMillis)
timeLimitMillis - the time limit in milliseconds.protected double getStrategyMove(Strategy strategy)
strategy - the strategy to acquire the move from.
protected double getStrategyMove(Strategy strategy,
boolean checkTimeLimit)
strategy - the strategy to acquire the move from.checkTimeLimit - if true checks whether to check the play time limit
constraints imposed.public double filterMove(double move)
move - the original move to filter.public final float getProbabilityOfMistake()
public final void setProbabilityOfMistake(float probabilityOfMistake)
public final void removeGameListener(GameListener gameListener)
public final java.util.Vector getGameListeners()
public void setBroadcastResult(boolean broadcast)
public void setBroadcastRoundResults(boolean broadcast)
public boolean getBroadcastResult()
public boolean getBroadcastRoundResults()
public final void addGameListener(GameListener gameListener)
protected final void broadcastResults(GameResult result)
protected final void broadcastRoundResults(GameRoundResult result)
protected final void broadcastGameStart(Game game)
public GameResult play()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||