InΒ [1]:
import axelrod as axl
alex, camille = axl.Alternator(), axl.TitForTat()
match = axl.Match([alex, camille], 10)
_ = match.play()
print(match.sparklines(c_symbol='πŸ˜€', d_symbol='🎁'))


πŸ˜€πŸŽπŸ˜€πŸŽπŸ˜€πŸŽπŸ˜€πŸŽπŸ˜€πŸŽ
πŸ˜€πŸ˜€πŸŽπŸ˜€πŸŽπŸ˜€πŸŽπŸ˜€πŸŽπŸ˜€

InΒ [2]:
family = [axl.Cooperator(),
...           axl.Defector(),
...           axl.Alternator(),
...           axl.TitForTat(),
...           axl.TwoTitsForTat(),
...           axl.Grudger()]
christmas = axl.Tournament(family, turns=50, repetitions=1)
results = christmas.play()
results.scores


Out[2]:
[[525], [562], [417], [622], [646], [646]]

InΒ [9]:
%matplotlib inline
evo = axl.Ecosystem(results)
evo.reproduce(100)
plot = axl.Plot(results)
plot.stackplot(evo)


Out[9]:

InΒ [5]:
def check_if_end_pop_cooperates(r=3, p=1, s=0, t=5,
...                                 digits=5, family=family, turns=10000):
...    """Returns a boolean and the last population vector"""
...    game = axl.Game(r=r, p=p, s=s, t=t)
...    christmas = axl.Tournament(family, turns=50, repetitions=1, game=game)
...    results = christmas.play()
...    evo = axl.Ecosystem(results)
...    evo.reproduce(turns)
...    last_pop = [round(pop, digits) for pop in evo.population_sizes[-1]]
...    return last_pop[1] == last_pop[2] == 0, last_pop

InΒ [6]:
check_if_end_pop_cooperates(r=3, p=1, s=0, t=5)


Out[6]:
(True, [0.16576, 0.0, 0.0, 0.26105, 0.28659, 0.28659])

InΒ [7]:
check_if_end_pop_cooperates(r=3, p=1, s=0, t=500)


Out[7]:
(False, [0.0, 1.0, 0.0, 0.0, 0.0, 0.0])