Iterated Prisoner's Dilemma

Outline your state machine here.

Prisoner's Dilemma How-To

This page allows you to create an entrant for the iterated prisoner's dilemma. Design a state machine and enter its parameters here. The output can be used in an Axelrod type tournament.

Designing Your Machine

Let's say that you want your strategy to be that you cooperate unless your opponent defects, in which case you defect on the next round. On the round after that, however, you go back to cooperating. So your first step is to design a state machine that reflects this strategy. An easy way to do this is to draw it. So let's do that. This is what this strategy looks like:

The red arrows indicate what happens when the opponent deviates and the green arrows show the action on cooperate. The first state is rectangular.

Data Entry

Now that you have your design, you need to communicate it to the computer. The first step in this process is to tell the computer how many states there are. So in the form on the first page, enter a name (I picked "Trusting") and the number of states (2). Then click the Next button and get ready to enter the values.

There are a couple things to note when entering data on the web forms. First, I'm fairly paranoid so there is a large set of characters that will just get eaten if you use them. Second, I'm lazy. So if you make a mistake in a form and click the "next" button, it will bring you all the way back to the beginning and forget everything you've told it. Some browsers will let you regain your lost data if you just hit the back button. If you do manage to find a cross-site scripting vulnerability, or just an error you don't think should be there, please do let me know about it.

On the next page, you'll be shown a table with state names and some radio buttons and text boxes. State 1 will be the cooperate state, while state 2 will be the deviate state. Check the appropriate buttons (row 1 column 1 and row 2 column 2) first. We'll have state 1 be our initial state, so click the button in the last column on the first row. Next is the rule making. If state 1 sees that its opponent cooperated, it will stay in state 1 to cooperate. If it sees a deviation, it will kick over to state 2 to deviate. So row 1's text boxes get a 1 and a 2, respectively. State 2 just always goes back to state 1, so put a pair of 1s in its boxes.

Now that the state machine is suitably defined, let's go on to the next step by clicking Generate.


Now the computer does some fancy thinking and spits out a nice picture of your state machine. Click the picture to get a program that you can enter as a contestant!

Running the Competition

The competition itself does not run on this web site for security and processor utilization reasons. You will be able to run one yourself after I get around to cleaning up and publishing the code for it. If you think that's a good idea and want me to prioritize it, let me know.

I have run a simulation with a few machines, but results won't be posted until after a bigger tournament later this year.


This feature is still sort of being tested, but you can also introduce an unpredictable factor to your state machines. To make a state with more than one possible outcome per input, the "Response To ..." fields get a new syntax. Instead of just putting the next state in the box, you can use a semicolon delimited list of state:probability pairs where probability is the % chance it will go to state. The probabilities have to be integers that add up to 100. The exception to this is that you can end your list with just a state and that state will use up whatever percent you have left.

So, for example, let's say I want a coin flipper that switches state 50% of the time no matter what the other person did. I would make a two-state machine with "1:50;2:50" in every field. The result would look like this:

Using the alternative syntax, I could also have put "1:50;2" or "2:50;1" or "2:50;1:50" in any fields.