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]:
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]:
InΒ [7]:
check_if_end_pop_cooperates(r=3, p=1, s=0, t=500)
Out[7]: