The Trader's Dilemma

A well known psychology experiment involves people playing a game in which they can either trade with each other or attempt to cheat the other player. If both players TRADE then each gains one point. If both CHEAT then each loses one point. However, if one TRADEs and the other CHEATs then the TRADEr loses two points and the CHEATer gains two.

Now you can participate in such a game. Develop a strategy in the form of a simple program obeying the following grammar:

program ::= statement.
statement ::= command | ifstat
ifstat ::= IF condition THEN statement ELSE statement
condition ::= cond | cond op condition
op ::= AND | OR
cond ::= memory { = | # } { command | NULL }
memory ::= { MY | YOUR } LAST{1|2|3|4|5|6|7|8|9}
command ::= TRADE | CHEAT

LAST1 refers to the previous encounter, LAST2 to the encounter before that, and so on. The symbol '#' means 'is not equal to'. NULL indicates that an encounter has not ocurred. Spaces and line breaks may appear anywhere in the program and are for readability only. Examples for valid programs are:

TRADE.
This is a program that always trades.

CHEAT.
And this is one that always cheats.

IF YOUR LAST1 = CHEAT THEN CHEAT ELSE TRADE.
This strategy is called "Tit for Tat" for obvious reasons.

So far there are four programs in my league. The three example programs mentioned above and my own personal strategy. Each program in the league plays 10 times against each other program. The current results are:

   Name            Score
1. Mark               16
2. Mr. Tit for Tat     7
3. Cheater             6
4. Trader            -27

Now develop your own strategy and send it in.


This page was last updated on January 3, 1996.

Mark Dettinger <mdetting@hydra.informatik.uni-ulm.de>