Prisoner's Dilemma
the Levinson version
Game Rules Read the Wikipedia page for the game background and history and then read the rules below. Note that rules written in this page take precedent for the purposes of the AI class.

A round is a series of games where every participant plays a number of games. Each game is played one-on-one with each person taking a turn to make a move. A player (or agent) has only two choices in each turn: 'C' for cooperation and 'D' for defection. Agents are unaware of their opponents' move. The outcome of the turn is evaluated by the monitor program after both agents have produced their output. The monitor calculates the point assignment after each move according to the following table:

Players

Player 1

C D
Player 2
C
D
3/3 0/5
5/0 1/1

P1/P2 payoff matrix

  • For our variant, each agent plays 3 moves per turn, where each move is "C" or "D". The output is in the form of a list of three plays.

  • Every time an agent plays (C or D) there's a F% chance that the player's hand is flipped (from C to D or vice versa). The chance of a flip occurring is calculated separately for each agent, for every turn. Thus it cannot be assumed that if an agent's hand is flipped this turn, the opponent's hand is also flipped this turn or that either will be more or less likely to be flipped later.

  • The chance of being flipped (F) will decay linearly according to this formula: F = F1 - (I)(M) where F1 is the initial F value given to the monitor. I is the decay factor and M is the number of moves that have been played in the game by the agent.

  • This means, the F number could be decreased by a constant factor, I, each turn. For example at the beginning: F=.25(25%) and I=.025. The chance of flipping on the first turn is 25%; on second turn it's 24.975%; on third turn it's 24.950%; etc.

  • Each game consists of a number of turns. The number of turns is semi-randomly determined between Lmin and Lmax and is uniformly applied for all agents, each round.

  • Each agent continues to accumulate points according to the payoff matrix throughout the game and carry over their points to the next round throughout the entire championship.

  • Each round is really a round-robin tournament. That is, every agent plays every other agent once. At the end of the round, the agent with the lowest score is dropped. If there's a tie for the lowest score, then all agents with that score are dropped out of the tournament.

  • This yields N-1 round-robins at most, where there are N agents participating.

  • The championship continues until all agents are eliminated. The agentor agents (if there is a tie) eliminated last win. But for the purposes of our assignments, all agents in the top quartile receive the same amount of points.

 

Agent Requirements An agent is a program that accepts two lists and outputs a list consisting of 3 moves where each move is either C or D. Important: because we will be running tournaments with tens of players, we need unique name spaces. It's absolutely crucial that you follow this naming convention for your agents.

Lastname1Lastname2

where each Lastname is the last name of team members capitalized. If there's only one person in the team, then there will be only one Lastname. If there are more, then list them alphabetically.

The declaration for the agent function should be like the following example:

(defun KhosmoodLevinson (hist score)

....

)

  • hist is a list of plays so far this game assuming the agent goes first:
    plays are (agent opponent) pairs, with the most recent play last.
  • score is an ordered (agent opponent) pair representing the total score for this game so far.

example of an agent being called in a game that already has had 2 turns with the score of 10-5, the agent is leading over its opponent.

(KhosmoodLevinson '((C D) (D C) (D C)) '(10 5))

Such a call should return a set of 3 moves which will be played one at a time against an opponent. For example:

(C C D)

 

Monitor Requirements The Monitor is a program that executes a tournament given a list of agents and some parameters for each game. A tournament consists of one or more round-robins (every agent plays every other agent) where after each round, the lowest scoring agent(s) are dropped.

Internally the monitor has a responsibility of running some number of rounds. For each round a semi-random gameLength is used for all games in that round. And for each game, there are flipParams that determine the chance of random flips on each move. Within each round, the monitor passes the game history and score-thus-far to each pair of agents in each game and receives those agents' moves in order to calculate the winner and point assignments.

Declaration of the monitor is the following:

(defun monitor (flipParams gameLength agents)

...

)

  • flipParams is a list of two items: '(F I)
    • F is the initial flip rate, the chance that each players move is flipped.
    • I is the increment of decay for F. If I is 0, then F remains the chance of flip for all turns in each game.
  • gameLength is a list of two items: '(Lmin Lmax) that determine the upper and lower bounds for a random game length per round. (1 30) means all the games in the round have T turns, where T is a random number between 1 and 30 inclusive. (25 25) means that all games in the entire tournament will be of length 25 turns.
  • agents is a list of defined agent functions who will be participating in this championship.

example of a monitor being called:

(monitor '(.25 .1) '(10 50) '(#'random #'titfortat #'bobs #'joes #'stoc #'coin #'janes #'dianefeinsteins #'chocalate #'cooperate))

  • output: the monitor will output an ordered list of all agents, sorted by the order of elimination. The last member of the list is the agent that was eliminated first and the first member of the list is the winner of the tournament, unless the first few agents had the same score.

example 1: ( (agentx 300) (agenty 225) )

example 2: ( (agentx 575) (agenty 425) (agentz 225) )