I have created a shell program called prisoner_main_v3.m which can be downloaded at the bottom of this page.
(This work owes much to someone else, before I started re-writing it for this workshop. The basic idea was provided to me in an email from a colleague who mentioned the source link. I am very sorry to say that the original communication has been lost so I am still looking for the right person to give some of the credit to.)
The shell program plays off different strategies against one another over a number of trials. The strategies are held as Matlab functions that return a string "defect" or "cooperate" the simplest of which is this:
function response = strategy_sucker(n,t,prev,all)
% n is where we are in the game
% t is the length of the game
% prev is what your partner did last time
% all is a list of all previous moves
response = 'cooperate';
end
The 'sucker' strategy merely returns 'cooperate' in all cases. All the strategies we developed at the workshop are now available to download. The shell program plays all the strategies off against one another and keeps a record of the scores achieved by each.
N.B. This code is pretty much as we left it after the workshop so will not be properly commented, and has also not been thoroughly tested.
Just download all the files below and put them in a directory, make this the current directory in Matlab and run the main program.