|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.generation5.ai.PrisonersDilemmaAgent
A simple implementation of an agent that obeys the rules of the prisoner's dilemma. This implementation contains five commonly-used strategies: all cooperate, all defect, tit-for-tat, pavlov, or random. For a more detailed look at the IPD and different strategies, please see the Generation5 essay.
| Field Summary | |
protected int |
agentPoints
Number of points agent has acquired |
static int |
ALL_C
Cooperate for all |
static int |
ALL_D
Defect for all |
static int |
COOPERATE
Cooperate with partner |
static int |
DEFECT
Defect against partner |
static int |
DREW
Drew the last round (returned by run) |
protected int |
lastRoundResult
What was the result of the last round? |
static int |
LOST
Lost the last round (returned by run) |
protected int |
myLastMove
The move this agent last played |
protected int |
partnerLastMove
What your opponent last played |
static int |
PAVLOV
Pavlov strategy |
static int |
RANDOM
Random strategy |
static int |
STRATEGIES
Number of strategies - for selecting random strategy |
static int |
TFT
Tit-for-tat strategy |
static int |
WON
Won the last round (returned by run) |
| Constructor Summary | |
PrisonersDilemmaAgent()
Default constructor (uses TFT strategy). |
|
PrisonersDilemmaAgent(int strategy)
Create a new instance of PrisonersDilemmaAgent with a given strategy. |
|
| Method Summary | |
void |
addPoints(int p)
Increment the points for the agent. |
int |
getMove()
Retrieve the agent's next move according to the current strategy. |
int |
getPoints()
Retrieve the number of points that the agent has acquired. |
int |
getStrategy()
Retrieve the strategy the PD agent. |
static void |
main(java.lang.String[] args1)
Simple test using an iterated prisoner's dilemma situtation. |
void |
reset()
Reset the agent's points, note that strategy remains untouched |
int |
run(PrisonersDilemmaAgent partner)
Make a run against your 'partner' with prisoner's dilemma rule. |
void |
setStrategy(int strategy)
Set the strategy type. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int ALL_C
public static final int ALL_D
public static final int TFT
public static final int RANDOM
public static final int PAVLOV
public static int STRATEGIES
public static final int COOPERATE
public static final int DEFECT
public static final int WON
public static final int DREW
public static final int LOST
protected int agentPoints
protected int partnerLastMove
protected int myLastMove
protected int lastRoundResult
| Constructor Detail |
public PrisonersDilemmaAgent()
public PrisonersDilemmaAgent(int strategy)
strategy - the strategy to use.ALL_C,
ALL_D,
TFT,
RANDOM,
PAVLOV| Method Detail |
public int getStrategy()
public void setStrategy(int strategy)
strategy - the strategy type.public void reset()
public int run(PrisonersDilemmaAgent partner)
partner - your partner for this run.
public int getMove()
public void addPoints(int p)
p - the number to increment the agent's point tally by.public int getPoints()
public static void main(java.lang.String[] args1)
args1 - not required.
|
This documentation is part of the Generation5 JDK.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||