How to play

The basic rules The computer's strategies
How to play Tips on strategies
Deciding your objectives Writing your own strategies

The basic rules of Dilemma

Dilemma (or Prisoner's Dilemma) is a game for two players, plus a third person acting as banker. In this version the computer acts as the second player, and as the banker - but don't worry, because the computer never uses its dual roles to gain unfair advantage (honestly!).

The rules are very simple. Each player has two cards, marked "cooperate" and "defect". In each round of the game, each player lays one of their cards face-down on the table (it doesn't matter who goes first). When both cards have been played, the banker turns them over and calculates the scores for that round. There are four possible combinations of cards, with the following scores:


Player A

Player B

Both cooperate

Both defect




As you can see, when both players cooperate, they both get a good reward. When both defect, they both get a much smaller reward. However when one cooperates and the other defects, it's the 'good' player who loses out, getting no points at all, while the 'cheat' gets the biggest reward of all. Such is life!

One other point is that you don't know how many rounds there will be in each game - it's chosen at random, and can be anything between six and 16. This makes choosing between long and short-term strategies much harder. That's a lot like life too.

The computer will play each game with one of its built-in strategies, chosen at random for each game (see below for details of the built-in strategies). It doesn't cheat, so never 'looks' at the card you've played in the current round before playing its own, and doesn't 'look' at the number of rounds in the game either. However it will take into account the cards you've played in previous rounds, just as you're free to analyse its previous cards. 

How to play the game

In this version of the game, you always play against the computer - you're on the left, and the computer's on the right.  (A version which allows you to watch the computer play against itself, using its own strategies, will soon be available at - watch that space!). 

You control the game via these four buttons:

The two right-hand buttons remain lit (functional) throughout the game, and are self-explanatory. The two left-hand buttons are for playing the 'co-operate' or 'defect cards', and are only lit when it's time for you to play a card.

When the page first loads, it starts a new game automatically, and the card-playing buttons light up. You choose which card to play in this round, and press the relevant button. The computer will play its card at a random point within five seconds. It doesn't matter which of you plays first, and you can take as long as you like to make your choice  

When you've both played, the card-playing buttons are switched off and the cards will look like this:

The game will then turn the cards face-over, like this:

and update the scores. 

It's now time for the next round of the game, so the buttons light up again for you to play your card. 

Alternatively the previous round may have been the last one of this game, in which case you'll see the 'Game Over' message. The number of rounds is chosen at random at the start of each game, and is always between six and 16. Neither you nor the computer's strategy functions know how many rounds the current game will have, which makes planning your moves that little bit harder!

When the game ends, the button changes to . Pressing it starts a new game. 

TIP - at the end of a game, the browser's status bar (bottom of screen) tells you how many rounds it contained, and the name of the strategy used by the computer:

The game history display

This area, between the second and third score displays, shows the round-by-round history of the current game so far. A butterfly indicates a 'cooperate' card , while a spider indicates 'defect'. The display starts at the bottom, and grows upwards, so the top entries are the most recent. The history display is your most valuable (only, in fact!) strategy tool when  playing Dilemma. By analysing it, you should be able to get some idea of which strategy the computer's using in this game, and adjust your strategy accordingly!

Deciding your objectives 

You can choose between two broad objectives when playing Prisoners' Dilemma. 

The first objective is simply to get more points than the other player, without worrying about how many points you actually score. This is called the 'zero sum game' approach, because it's just the winning or losing that matters, and these balance each other out regardless of how many points were involved. It's the way most sports are organised, especially knockout competitions such as football cup ties, where a 1-0 win is as good as a 10-0 one.

The alternative objective is to get a high points score for yourself, without worrying about whether you've got more than the other player or not. This is called a 'non zero-sum game' approach, because it's the number of points accumulated that matter, not just a simple win/lose balance, and in those circumstances both players can come out 'winners'. 

The non zero-sum objective is more representative of real life. For example, most people would think it better to have 100,000 while their neighbour has 110,000, than to have 100 while their neighbour has 80. It's also better for two companies to do well than for one to end up in near-bankruptcy having driven the other out of business. 

You can take the non zero-sum approach a stage further, and consider your ultimate objective to be the good of the community as a whole, i.e. not just how many points you score, but how many points you and the other player accumulate between you, and thus add to the communal wealth. This is the purpose of the third (right-hand) score display in the game, which shows you the combined totals of both players (all three score coiumns include average as well as total scores, so you can compare games with differing numbers of rounds). 

If you're really community-minded, watch the effect on the combined average of someone playing a Defect card - it goes below the optimum (all-cooperation) level, and can never recover!

The Computer's Strategies

The game comes with four built-in strategies:

The game doesn't tell you which strategy it's using during a game, but does display the strategy name in the browser's status bar when the game finishes.

Tips on strategy

The ultimate zero-sum strategy is to defect every time ('Always Defect'). This will always get you a win over the tit-for-tat strategy, since Tit-for-Tat always plays cooperate in the first round. It will also achieve a win over most random and adaptive strategies, since they will normally let their guard down at some point, play cooperate, and give you a top score. However you won't score many points overall, since only the most gullible or generous strategies will play cooperate against you very often. 

Against an Always Defect strategy (represented in this game by Random Defects with a very high percentage-defects value), your only option is to always defect yourself - unless, that it, you're the ultra-altruistic type who's happy to see the overall wealth of the community increase through your opponent's ill-gotten gains (see 'Always Cooperate' below). If you really can 'turn the other cheek' like that, then you're a finer human being than most of us. On the other hand, if meeting Always Defect makes a defector out of you, you can reflect on how quickly our morals crumble when faced with insuperable evil and the need to survive. 

The best personal non zero-sum game strategy - in fact the best strategy, according to The Selfish Gene - is Tit-for-Tat. This strategy is 'nice' and 'forgiving', so wants to cooperate and is willing to let bygones be bygones, generating lots of cooperation when it's treated fairly. However it's also unyielding in its insistence on striking back against defects, so opponents with any intelligence will soon learn not to mess around with it (TIP - don't, however, assume that the computer's strategies have any intelligence!).  

Against Tit-for-Tat - well, you don't really have much choice, do you? You can defect against it on the first round, but unless you let it have a cooperate-defect round back, you'll end up locked into a defect-defect sequence that will see both of you score very few points. That's OK if you're a die-hard zero-summer, but if you like actually seeing some digits on the scoreboard, your only real option is to play fair against it, pocket those nice cooperate-cooperate payouts, and not get envious of your opponent's points total.

The ultimate community-oriented, non zero-sum strategy is Always Cooperate, in which you play co-operate whatever your opponent has done to you. It can generate high combined points scores, although this may be largely due to your opponent walking off with lots of juicy cooperate-defect scorelines! These won't be as high as when both players co-operate all the time, but at least you'll have done your bit!

If you find yourself playing against Always Cooperate (represented in this game by Random Defects with a very low percentage-defects value), then you really do have a moral dilemma. You can reciprocate its honesty, pocket lots of nice cooperate-cooperate payouts, and watch the community's wealth grow as the combined scores go through the roof. Or you can take that sucker for everything it's got, bank those gorgeous defect-cooperate bonanzas, and let the community take care of its own problems. Which kind of player are you?

Writing your own strategy functions

You can add your own strategy functions to the Dilemma game. All you have to do is write the functions (keeping strictly to the specifications), add them to the source document, and make one small change to the page's existing source code. Your function(s) will then be available for random selection at the start of each game.

For details of the strategy function specifications, see "Paul's Web Design Pages" at You'll also find a downloadable .zip file there containing a complete copy of the game files. You can use these to experiment with strategies on your PC. 

If you'd like your strategy added to the online game here at, then send it to I'll only publish the best, and be warned - I'll be keeping an eagle-eye open for cheating!!

Meanwhile, over at, we'll be publishing an upgrade version of the game which will allow two computer strategies to play against each other. DNJ (Developer Network Journal) also plans to run a tournament to find the best strategy, with prizes for the top perfomers. Subscribers to my mailing list will be notified automatically when the competition begins.

This help file (C) Paul Stephens, 1999