If you're not familiar with the The Prisoner's Dilemma, it's the go-to example for describing game theory. Here's a quick explanation of how it works:

Two individuals are each presented with a choice between two options: to Defect or to Cooperate.

Defecting means an individual will betray the other in order to receive a beneficial outcome for them self and a negative outcome for the other.

Cooperating means an individual is hoping the other individual will choose to cooperate as well, in which case they would both get a slightly beneficial outcome.

Neither will know what choice the other has made until after they have both made a decision.

If you were to play this scenario out only once, the best course of action for either individual would be to defect. However, that's not all that interesting. What's more interesting is when this scenario is played out in a slightly different way dozens, or hundreds, or millions of times. When given the ability to remember at least the last few encounters you have with one individual, the rules of the game change dramatically. Knowing what prior choices your opponent has made open up a world of possibilities; many different strategies. This leads us to the Iterated Prisoner's Dilemma.

So what did I do with this information? Coded it in PHP, of course. I created over a dozen different strategies, and pitted them against one another in over two and a half million iterations of the Prisoner's Dilemma. For each iteration, the two opponents' strategies were chosen randomly. Here are the results:

An interesting next step would be to extend this further to test the effect population has on the success of each individual strategy. In other words, if Tit for Tat made up only 2% of the population, and some more malicious strategies made up a large chunk of the population, would the Tit for Tat strategy fair better or worse?

If you're interested, the code is available in a GitHub repository. If you are feeling inspired, please feel free to fork it or submit a pull request.