T
theglazeb
Hi there!
I was wondering if you were able to help with me a basic prisoner's
dilemma strategy? How would I implement a basic tit for tat strategy?
And perhaps try to avoid the "death spiral" from occurring when two
players use the tit for tat strategy?
See below
Thanks!
/*
* File: PDStrategy.java
* ---------------------
* This class encapsulates the strategy for an Iterated Prisoner's
* Dilemma game. To enter the contest, all you have to do is change
* the definition of chooseAction so that it takes account of the
* history and does something more clever than cooperating (or
* defecting) all the time.
*/
import java.util.*;
class PDStrategy {
/*
* Method: chooseAction
* --------------------
* This method determines the player's action for the current
* game, based on two ArrayLists containing the history of play:
* one for your algorithm and one for the opponent. Each of these
* ArrayLists contains strings, which are guaranteed to be one of
* the uppercase strings "COOPERATE" or "DEFECT". Your method
* should look at the history and return one of those two strings
* representing the action you take on the current round.
*/
public String chooseAction(ArrayList<String> myHistory,
ArrayList<String> oppHistory) {
return "COOPERATE"; //currently, it is only cooperating
}
}
I was wondering if you were able to help with me a basic prisoner's
dilemma strategy? How would I implement a basic tit for tat strategy?
And perhaps try to avoid the "death spiral" from occurring when two
players use the tit for tat strategy?
See below
Thanks!
/*
* File: PDStrategy.java
* ---------------------
* This class encapsulates the strategy for an Iterated Prisoner's
* Dilemma game. To enter the contest, all you have to do is change
* the definition of chooseAction so that it takes account of the
* history and does something more clever than cooperating (or
* defecting) all the time.
*/
import java.util.*;
class PDStrategy {
/*
* Method: chooseAction
* --------------------
* This method determines the player's action for the current
* game, based on two ArrayLists containing the history of play:
* one for your algorithm and one for the opponent. Each of these
* ArrayLists contains strings, which are guaranteed to be one of
* the uppercase strings "COOPERATE" or "DEFECT". Your method
* should look at the history and return one of those two strings
* representing the action you take on the current round.
*/
public String chooseAction(ArrayList<String> myHistory,
ArrayList<String> oppHistory) {
return "COOPERATE"; //currently, it is only cooperating
}
}