|
Evolving Strategies for the Prisoner's Dilemma | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--ie.errity.pd.Prisoner
This class represents a Prisoner with a strategy to play the
Prisoner's Dilemma Game.
| Constructor Summary | |
Prisoner(java.util.BitSet strat)
Create a new Prisoner to play the prisoners dilemma (nameless) |
|
Prisoner(java.lang.String s)
Create a Predefined Prisoner |
|
Prisoner(java.lang.String na,
java.util.BitSet strat)
Create a new Prisoner to play the prisoners dilemma |
|
| Method Summary | |
java.lang.Object |
clone()
Copy the current Prisoner |
java.awt.Color |
getColor()
Return which color to render the prisoner (based on it's strategy) In order to differentiate between different 'types' of player this method sets color according to how often the Prisoner will cooperate and how often they defect Orange/Red signifies defecting ('nasty') strategies Yellow/Green signifies cooperating ('nice') strategies Blue indicates balanced strategies |
java.lang.String |
getName()
Returns the Prisoner's name |
static Prisoner |
getRand()
Returns a Prisoner with a random strategy |
static Prisoner[] |
getRand(int num_players)
Returns an array of Prisoners with random strategies |
static Prisoner[][] |
getRand(int num_players,
int num_players2)
Returns a 2D array of Prisoners with random strategies |
int |
getScore()
Returns the Prisoner's current score |
java.util.BitSet |
getStrat()
Returns the Prisoner's strategy |
int |
getType()
Return the strategy 'type' of the prisoner 0,1,2 signifies defecting ('nasty') strategies 5,6,7 signifies cooperating ('nice') strategies 3,4 indicates balanced strategies |
boolean |
play(int iteration,
java.util.BitSet History)
Gets the Prisoner's next game move |
void |
setScore(int s)
Set the Prisoner's current score |
java.lang.String |
toString()
Convert the Prisoner's strategy to a string of C's and D's |
int |
updateScore(int s)
Adds value to the Prisoner's current score |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Prisoner(java.lang.String na,
java.util.BitSet strat)
na - the Prisoner's namestrat - a BitSet representing the player's strategypublic Prisoner(java.util.BitSet strat)
strat - a BitSet representing the player's strategypublic Prisoner(java.lang.String s)
s - the name of a predefined prisoner TFT - Tit for TatTFTT - Tit for Two TatsALLC - Always cooperateALLD - Always defect| Method Detail |
public int updateScore(int s)
s - the value to be added
public int getScore()
public void setScore(int s)
s - the new scorepublic java.lang.String getName()
public java.util.BitSet getStrat()
BitSet representing the strategy
public boolean play(int iteration,
java.util.BitSet History)
iteration - current iteration numberHistory - game history represented as a BitSet
true or false {C or D}public java.lang.Object clone()
clone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic static Prisoner getRand()
public static Prisoner[] getRand(int num_players)
num_players - the number of Prisoners to create
public static Prisoner[][] getRand(int num_players,
int num_players2)
num_players - the length of array to returnnum_players2 - the depth of array to return
public java.awt.Color getColor()
public int getType()
|
Andrew Errity [99086921] | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||