Battle Applet

D. Joyce, J. Kennison, N. Thompson
Departments of Mathematics and Psychology
Clark University
May, 2002



The Battle Applet. See below for an explanation.








Nice
Nasty
Tit4Tat
Moth
Hit&Run
Santa
NasMoth
NNHRun


The game and its players.

Two players play, called partners. In each game, each player has two options. It can cooperate or defect, and there will be payoffs to each according to a Prisoners' Dilemma matrix. You can see the 2 by 2 payoff matrix in the applet window, and you can change it if you like. It looks like

CD
C
D
30
51

The row labelled C says what cooperators will score, while the row labelled D says what defectors will score. The columns are also labelled C and D and indicate whether the player's partner did. So

On the face of it, it looks like you get more points if you defect than if you cooperate.

Stringing games together into a match.

Now, suppose instead of just playing one game with your partner, you have to play several, say 20, in a match. This allows for strategies where how you play in one game depends on the results of the previous games. In particular, if you and your partner continue to cooperate, you can rack up many points together.

But racking up many points together doesn't mean much when your goal is to get more points than your partner. So the scenario has to change somehow to make that your goal. One way to do this is to have more than just two players, say 80, ranodomly pair them into parterships and have the partners play matches. Your goal is to score high among all the players, not just higher than your partner.

Breaking the partnership.

Enforced partnerships for many games in a match may seem a little artificial to the players. After all they have to compete with all the players, and being stuck with a particularly nasty partner could cause you to quit entirely and seek another partner. Let's suppose we allow that. Players may unilaterally break partnerships any time during the match, and resume playing with other partnerless players. Of course, if just one parnership breaks up after a game, they'll have to pair back up for the next. We'll assume that after each game, whatever partnerless players there are will pair up randomly.

The strategies.

There are many possible strategies to play a match. We'll consider these eight.

Evolution, a way to valuate strategies.

One way to evaluate strategies is to have an number of players, say 10, for each strategy, and instead of playing just one match, let them play several, each time randomly paired with another player.

Better than that would be to use the scores on one match to determine the players of the next match. Let those strategies that performed well in one match be assigned more players in the next match, and those that performed poorly be assigned fewer players in the next match.

The simulation.

The players (initially the same number of each kind), are paired off randomly. Simultaneously, each pair plays a single game. After that game, either player or both may decide to leave the partnership, in which case the partnership dissolves and both players have to be repaired for the next game; if neither want to leave, the partnership remains intact for the next game. In all, there will be an even number of players that will need new partners for the next game, and those will be paired off randomly.

A number of games (say 20) form a match. At the end of a match, scores for each player are tallied, and the number of players of each kind of strategy for the next match will be proportional to the total score for all the players of that strategy. For instance, suppose there are 45 Nice players with a total score of 1000 and 55 Nasty players with a total score of 1500 (and no other players), then in the next match there will be 40 Nice players and 60 Nasty players, since 1000:1500 = 40:60. If the proportion doesn't come out perfect, a random assignment will be made to approximate the right ratio.

Thus, a number of matches (say 20) will be simulated, each with different proprotions of the various strategies.

Reports.

At the end of this sequence the simulation ends, and the applet produces two reports. One is a one-line report.
Nice	Nasty	Tit4Tat	Moth	Hit&Run	Santa	NasMoth	NNHRun
1	0	0	78	0	0	1	0
This report indicates how may players of each kind remained at the end of the sequence of matches. After that, an entire new sequence of matches is simulated starting with new players, an equal number of each kind. At the end of that simulation, the applet prints another line. This continues until you press the "Stop" button. Then the totals for all of the simulations are printed. Here's an example
Nice	Nasty	Tit4Tat	Moth	Hit&Run	Santa	NasMoth	NNHRun
2	0	0	77	0	0	1	0
0	0	0	79	0	0	1	0
0	0	0	79	0	0	1	0
0	0	0	79	0	0	1	0
7	0	1	71	0	0	1	0
0	0	0	80	0	0	0	0
0	0	0	79	0	0	1	0
7	0	0	71	0	0	2	0
9	0	5	66	0	0	0	0
10	0	0	69	0	0	1	0

Totals for 10 simulations.
Nice	Nasty	Tit4Tat	Moth	Hit&Run	Santa	NasMoth	NNHRun
35	0	6	750	0	0	9	0
______________________________________________________________
Notice how Moth does so well.

The other report is a color-coded graph which shows the relative populations of the eight strategies. At the beginning of the simulation, the populations are equal, and on the left you can see color has the same height. At the end of each match, the populations for the strategies are reallocated, so some colors get thicker, some thinner. Poor Santa never lasts very long (unless you fiddle with the playoff matrix).

Applet controls.

The Start/Stop button starts and stops the simulations.

The Reset button resets the parameters.

There are three parameter values that can be changed:

These parameters are fixed for each simulation. Changes take effect on the next simulation (reported on the next line).

A few comments.

By setting the number of matches/simulation to 1, 2, 3, etc, you can see the effect of selecting strategies for players based on scores. Set to 1, you'll see that some strategies are favored over others, but not to exclusion.
Nice	Nasty	Tit4Tat	Moth	Hit&Run	Santa	NasMoth	NNHRun
10	9	9	12	12	6	15	7
6	12	7	11	13	6	16	9
7	9	8	11	15	7	15	8
9	8	8	10	12	7	16	10
7	7	11	11	14	6	16	8

Totals for 5 simulations.
Nice	Nasty	Tit4Tat	Moth	Hit&Run	Santa	NasMoth	NNHRun
39	45	43	55	66	32	78	42
______________________________________________________________
But even by the time there are about 7 matches/simulation, a couple of strategies are wiped out, and all but Moth are virtually gone by 20 matches/simulation.

By setting the number of games/match low, you'll see how important interaction between players becomes. When there's only one game/match, then a strategy's first play, and whether it stays or leaves are the only things that matters. The nastier strategies do better. When there are two games/match, things aren't much different, but Moth is starting to do better. By three games/match interesting things happen since very different outcomes occur in the different simulations, with Moth wiped out in some simulations, but in others the nasties are wiped out. Somewhere around 10 to 12 games/match the nasties are nearly always wiped out.

Source code.

There are a number of Java classes for this applet.

The files for this applet are listed here. The Moth.html
file is this file you're looking at. The Battle.java files
are the program source files for the applet. The *.class
files are the compiled files that run when the applet is
running. They're all needed to run the applet.


My way Or The Highway: Introduction


David E. Joyce,
John Kennison,
both of the Department of Mathematics and Computer Science,
and Nicholas Thompson,
of the Frances L. Hiatt School of Psychology.
Clark University
Worcester, MA 01610