<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Modulo Errors &#187; Matlab</title>
	<atom:link href="http://maths.straylight.co.uk/archives/category/matlab/feed" rel="self" type="application/rss+xml" />
	<link>http://maths.straylight.co.uk</link>
	<description>for when the margin is too small</description>
	<lastBuildDate>Thu, 12 Jan 2012 16:36:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Iterated prisoner&#8217;s dilemma in MATALB</title>
		<link>http://maths.straylight.co.uk/archives/44</link>
		<comments>http://maths.straylight.co.uk/archives/44#comments</comments>
		<pubDate>Mon, 27 Mar 2006 19:04:59 +0000</pubDate>
		<dc:creator>Graeme</dc:creator>
				<category><![CDATA[Game Theory]]></category>
		<category><![CDATA[Matlab]]></category>

		<guid isPermaLink="false">http://maths.straylight.co.uk/archives/44</guid>
		<description><![CDATA[MATLAB Code for running IPD tournaments.]]></description>
			<content:encoded><![CDATA[<p>
To assist with my upcoming project on game theory, I&#8217;ve put together some MATLAB functions to run iterated prisoner&#8217;s dilemma tournaments. In particular, this demonstrates the effects of the Southampton strategy I described a while ago <a href="http://www.everything2.com/index.pl?node_id=1681406">on E2</a>. MATLAB&#8217;s vector operations turned out to be particularly well suited to this, especially for handling unknown competition length or numbers of participants. The files are reasonably well documented, but I thought I&#8217;d offer some additional guidance.
</p>
<p>
Drop the files below into the same directory and run the <i>tournament</i> script to generate some sample output. Each program plays every other for the specified number of rounds, including itself, then a total score is obtained for each. The matrix returned gives the scores of individual pairings in the natural way; the vector is the scores. You can adjust the identities of the players by altering the vector Q defined in <i>tournament</i>; any number of players and any choice of strategies should work (including, of course, repeated instances of any given strategy).</p>
<p><i>play</i> handles any given play of the game, that is, one round between two strategies, with their respective histories available. I&#8217;ve implemented always cooperate, always defect, tit-for-tat, grim, and the southampton master/slaves. Any unrecognised strategy code is treated as a random 50/50 choice, and the addition of further strategies should be fairly smooth- add another if condition that tests for your chosen number, then add that number into the player vector Q to see it in action. </p>
<p>I don&#8217;t know the precise details of the Southampton programs, but mine work along the same lines. A sequence of 8 moves codes for each; during the first 8 rounds, each program continues to play its signal moves unless the opponent has signalled incorrectly. From round 9 onwards, the programs will have identified their opponent as southampton slave, master or non-southampton. In the case of the latter, both strategies switch to permanent defection to reduce the opponent score. In a master-slave pairing, the master defects and the slave cooperates to maximise return to the master at the cost of the slave. Master-master or slave-slave pairings play out as mutual cooperation to bolster their scores.
</p>
<p>The payoff matrix I use is consistent with my report, but not exactly standard. This of course can also be changed.
</p>
<p><strong>Source</strong>:<br />
<a HREF="http://maths.straylight.co.uk/games/iteratedpd.m">[iteratedpd.m]</a><a HREF="http://maths.straylight.co.uk/games/play.m">[play.m]</a><a HREF="http://maths.straylight.co.uk/games/rounds.m">[rounds.m]</a><a HREF="http://maths.straylight.co.uk/games/tournament.m">[tournament.m]</a></p>
]]></content:encoded>
			<wfw:commentRss>http://maths.straylight.co.uk/archives/44/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

