Package pd

API for strategies ("agents") which play the iterated Prisoners Dilemma game.

See: Description

Package pd Description

API for strategies ("agents") which play the iterated Prisoners Dilemma game. To write an agent, either:

In either case, the strategy goes in the agent's PrisonersDilemmaAgent.run() method. It works by commanding a PrisonersDilemmaActor which performs actions in the PrisonersDilemmaGame. The actor also provides all available information from the game. Here's a sample run method that implements TIT FOR TAT:

public void run() {
  PrisonersDilemmaGame game = actor.getGame();
  
  // first move:
  IterationResult result = actor.cooperate();
  
  // subsequent moves:
  while (game.isRunning()) {
    result = actor.act(result.otherPlayerAction);
  }
}
See the Agent docs for details.