Showing posts with label Prisoners Dilemma. Show all posts
Showing posts with label Prisoners Dilemma. Show all posts

Thursday, 27 February 2014

Iterated Prisoner's Dilemma with a twist in Class

In my last blog post I described the iterated prisoner's dilemma tournament that my students played in class: 'Iterated Prisoner's Dilemma Tournament in Class'. This was great fun and one team even got the idea of how to define a strategy in a repeated game.

That class activity corresponded to this chapter of my class during which we looked at subgame perfect Nash equilibrium.

Let us look at the Prisoner's dilemma that we played:

\[\begin{pmatrix}
(2,2)&(5,0)\\
(0,5)&(4,4)
\end{pmatrix}\]

If both players cooperate for 3 rounds then they both get a utility of \(2\times3=6\).

The next chapter of my class looks at what is called 'infinitely repeated games', in this it is assumed that players play an infinite number of rounds. We use the usual mathematical trick to handle infinite sums so that we can compute finite utilities.

For example the utility to both players for always cooperating is given by:

\[\sum_{t=1}^{\infty}\delta^{t-1}2=\frac{2}{1-\delta}\]

Where \(0 < \delta < 1\).

The utility to both players always defecting is given by:

\[\sum_{t=1}^{\infty}\delta^{t-1}4=\frac{4}{1-\delta}\]

The 'discounting factor' \(\delta\) allows us to compare these two strategies: if both players defect they do worse then if they both cooperated.

There are various interpretations for \(\delta\), one of which is the probability with which a game continues (ie we allow for the possibility for the game to end at each round), thus the above calculation become an expected value calculation.

To illustrate this I brought a dice in to class and had +Jason Young run a tournament during which the game could end based on a chosen probability.

Here are the first set of results (we played with \(\delta=.75\) so we carried on as long as my d20 < 16):


Team Laurence got pretty lucky (players are here trying to reduce the 'amount of time they spend in prison') with their roles and twice only had to play one round!

Here's the overall standings (as well as some other details):


Team Cymru's huge score can be explained by two factors: lack of luck with the dice and they also formed a coalition with team Laurence.

After this we still had 30 minutes spare in the class so I offered ending there or playing another round. My students made me smile by mostly staying and playing another round. In fact they even pointed out that technically they shouldn't be able to watch the progression of the game (ie seeing how other teams were acting). So they suggested that the teams who weren't playing would go stand in the corridor (I thought this was cool to come from them).

We also changed the value of \(\delta\) to \(.25\) (so games only continued 25% of the time). Here are the results:


This is the last round (they're on separate boards because I had to hide/erase/etc...):


The outcome was team Roy and Cymru both tied for the win at 8 (Roy did this with well timed defections and Cymru managed to cooperate successfully a couple of times).

At this point I wasn't really sure what to use as a tie breaker but someone in class yelled: 'Rock, Paper, Scissors, Lizard, Spock'. We actually played this in class a while back when we started looking at mixed strategies, I blogged about it here: 'A Rock, Paper, Scissors, Lizard, Spock Tournament in class'

Here's the outcome of that:


Joe won it for team Roy.

This was great fun and will hopefully be useful to help my students contextualise one of the ideas of this chapter: it's actually possible to find a value of \(\delta\) for which students should cooperate. I'm not sure this was made evident by the activity but we did see more cooperation for lower values of \(\delta\).

Sunday, 23 February 2014

Iterated Prisoner's Dilemma Tournament in Class

On Friday my students and I played an iterated Prisoner's Dilemma tournament in class.

This is something that I've run many times before with +Paul Harper during outreach events and I've blogged about it here and +Dana Ernst ran something similar and blogged about it here (both those posts also talk about 2/3rds of the average games).

The way I do this is to split the class in to 4 teams and play a round robin of a set of 5 to 8 repetitions of the Prisoner's Dilemma:



The particular version of the game I usually use is given below:

\[
\begin{pmatrix}
(2,2)&(5,0)\\
(0,5)&(4,4)
\end{pmatrix}
\]

The utilities represent 'years in prison' and over the 3 matches that each team will play (against every other team) the goal is to reduce the total amount of time spent in prison.

This is always good fun and my final year students were no exception (more so that +Paul Harper leant me a sidekick who was allowed to use a Nerf gun when the opposite team defected - more about that here):






In this particular instance we played 8 rounds per 'duel' and it was very helpful to have +Jason Young assist me with writing down the scores etc...

Here's the overall scores which show that the team named: 'Cymru' acquired the least total score (and won a box of chocolate):


Here's all the 'duels':


The 3rd game was the most interesting (from an educators point of view).

Team 'Roy' at the very beginning of the duel stated:

'We will cooperate until you defect, once you defect we will only defect'

Both teams cooperated fully and in the final round Roy defected (whilst their opponent continued to cooperate). This all happened with no prompting from myself which is great because team Roy in effect discovered how strategies had to be defined in repeated games which must take in to account the entire history of the game.

What's also quite cool is that they described 'Tit for Tat' the strategy that won Axelrod's tournaments.

+Michael Trick pointed out that that is completely incorrect and that Roy almost described 'Tit for Tat', they in fact played what's called 'grudger' (which did not win Axelrod's tournaments).

What happened in the last two rounds of the game was also pretty interesting as some coalitions formed to try and share the box of chocolates. Some of my students showed some great game theoretical reasoning: 'we will give you all but enough chocolates for each one of us on the team'...

In class we will consider repeated games in a more rigorous setting and before playing infinitely repeated games also play a modified version of this tournament (I'll blog about that when it happens).

(Note that the name of the winning team: Cymru is Welsh for Wales and I think was partly motivated by the fact that I was wearing my French rugby shirt before the Wales France game that evening. Wales played extremely well and thrashed France.)