|This is a simple example of a Python agent that plays Tit For Tat. First it cooperates, then it does whatever the other player did on the previous round.||from java.lang import Runnable|
You write your agent as a Python class that has a
Here we put the
|class TitForTat(Runnable): def run(self): actor = self.actor game = actor.getGame()|
Here is the strategy. After the initial cooperation, the agent runs a loop which executes until the game is done.
||result = actor.cooperate() while (game.isRunning()): result = actor.act(result.otherPlayerAction)|
|A longer Python example can be seen at genetic_prisoner.|
PyTitForTat Annotated source code