Lesson 19. Capstone: The prisoner’s dilemma

 

Let’s pretend you’ve been given the honor of organizing a hack-a-thon—a programming competition where competitors are given a coding challenge they’re expected to solve.

Being the lover of game theory that you are, you decide to use the prisoner’s dilemma as the challenge for the hack-a-thon. How did I know you are a lover of game theory, you ask? Ahem, who isn’t? But on the off chance that you’re not, I’ll explain the prisoner’s dilemma. Two prisoners are interrogated in separate rooms, each asked to snitch on the other prisoner. Exactly what happens when each prisoner snitches on the other changes depending on who tells the story, but the basic idea is this. The best outcome for both prisoners is if neither snitches on each other. If one snitches on the other, it’s good for the one who snitched but bad for the one getting snitched on. If they both snitch on each other, it’s bad for both, but less severe than being the only one getting snitched on. For the purpose of the hack-a-thon, you decide the outcomes are as follows:

  • If both prisoners snitch, they each serve one year.
  • If only one prisoner snitches, that prisoner goes free and the other serves two years.
  • If neither prisoner snitches, they both go free.

19.1. Generating prisoners

19.2. Getting prisoners to interact

19.3. Getting and storing the results

19.4. Putting the simulation together

19.5. Which prisoner does best?

Summary