Homework 15. Evolution of Cooperation.
Pledged. No prelab, No first draft, No consulation with anyone other than the two instructors.
Final Draft due 5pm Wednesday, December 19

We shall reproduce the findings of May and Nowak on Evolutionary Games and Spatial Chaos.

The game takes place on an M-by-N board. Each square is occupied by a cooperator (C) or a defector (D).

In a given round each square plays prisoner's dilemma with each of its immediate neighbors, including itself. Each square has either 4, 6, or 9 such neighbors. The payoffs are as follows

  C vs. C, each receives 1
  C vs. D, C receives 0 and D receives b
  D vs. D, each receives 0
The score of a square is the sum of the neighborly payoffs.

At the next generation, each square assumes the identity of the winner (highest scorer) of the last neighborly round.

For example, the score of the board

   D  D  D         b 2b  2b                                           D  D  C
   D  C  C   is   3b  5  4   and so if b=1.9 the next generation  is  D  D  C
   C  C  C         3  5  4                                            D  D  C
We monitor the game's progress by
   painting a square blue when C remains C
   painting a square red when D remains D
   painting a square yellow when C becomes D
   painting a square green when D becomes C
You will write the

   function evo(M,N,b,gen)

that plays this game for gen generations, commencing from a board of cooperators with a lone defector at its center (when M and N are odd). With M=N=99 and b=1.9 you will find boards like

after 10 and 100 generations respectively. It is fascinating to watch the fraction of cooperators ebb and flow. You will want to quantify this in a graph of the form

I recommend that evo delegate to three subfunctions

   function S = score(A,b)
   function An = advance(S,A)
   function evodisp(A,An)

where A denotes the state of the previous generation. The state is the matrix of identities (C or D, simlilar to live and dead) of each of the players.

Your work will be graded as follows


   Final Draft, 110 points total

     8 pts for headers CONTAINING detailed USAGE
     8 pts for further comments in code 
     4 pts for indentation
     20 pts for correct score function
     30 pts for correct advance function
     20 pts for correct evodisp function
 
       in the following, suppose  M=N=99, b=1.9, 
       starting from the C board with lone center D

     5 pts for jpeg of generation 101 

     5 pts for jpeg of generation 200 

     10 pts for jpeg of Fraction of Cooperators, up to gen=300