Probabilistic Ending TournamentsΒΆ

It is possible to create a tournament where the length of each Match is not constant for all encounters: after each turn the Match ends with a given probability, [Axelrod1980b]:

>>> import axelrod as axl
>>> players = [axl.Cooperator(), axl.Defector(),
...            axl.TitForTat(), axl.Grudger()]
>>> tournament = axl.Tournament(players, prob_end=0.5)

We can view the results in a similar way as described in Accessing tournament results:

>>> results =
>>> m = results.payoff_matrix
>>> for row in m:  
...     print([round(ele, 1) for ele in row]) # Rounding output  

[3.0, 0.0, 3.0, 3.0]
[5.0, 1.0, 3.7, 3.6]
[3.0, 0.3, 3.0, 3.0]
[3.0, 0.4, 3.0, 3.0]

We see that Cooperator always scores 0 against Defector but other scores seem variable as they are effected by the length of each match.

We can (as before) obtain the ranks for our players:

>>> results.ranked_names  
['Defector', 'Tit For Tat', 'Grudger', 'Cooperator']

We can plot the results:

>>> plot = axl.Plot(results)
>>> p = plot.boxplot()

We can also view the length of the matches played by each player. The plot shows that the length of each match (for each player) is not the same. The median length is 4 which is the expected value with the probability of a match ending being 0.5.

>>> p = plot.lengthplot()