1010import axelrod as axl
1111from axelrod .graph import Graph
1212
13+
1314def few_players_no_mutations ():
1415 edges = [(0 , 1 ), (1 , 2 ), (2 , 3 ), (3 , 1 )]
1516 graph = Graph (edges )
16- players = [axl .Cooperator (), axl .Cooperator (), axl .Cooperator (), axl .Defector ()]
17+ players = [
18+ axl .Cooperator (),
19+ axl .Cooperator (),
20+ axl .Cooperator (),
21+ axl .Defector (),
22+ ]
1723 mp = axl .MoranProcess (players , interaction_graph = graph , seed = 40 )
1824 _ = mp .play ()
1925
26+
2027def few_players_mutations ():
2128 edges = [(0 , 1 ), (1 , 2 ), (2 , 3 ), (3 , 1 )]
2229 graph = Graph (edges )
23- players = [axl .Cooperator (), axl .Cooperator (), axl .Cooperator (), axl .Defector ()]
24- mp = axl .MoranProcess (players , interaction_graph = graph , mutation_rate = 0.5 , seed = 40 )
30+ players = [
31+ axl .Cooperator (),
32+ axl .Cooperator (),
33+ axl .Cooperator (),
34+ axl .Defector (),
35+ ]
36+ mp = axl .MoranProcess (
37+ players , interaction_graph = graph , mutation_rate = 0.5 , seed = 40
38+ )
2539 for _ in range (100 ):
2640 try :
2741 mp .__next__ ()
2842 except StopIteration :
2943 break
3044
45+
3146def four_distinct_players_no_mutations ():
3247 players = [axl .Cooperator (), axl .Defector (), axl .TitForTat (), axl .Grudger ()]
3348 mp = axl .MoranProcess (players , seed = 40 )
3449 _ = mp .play ()
3550
51+
3652def four_distinct_players_mutations ():
3753 players = [axl .Cooperator (), axl .Defector (), axl .TitForTat (), axl .Grudger ()]
3854 mp = axl .MoranProcess (players , mutation_rate = 0.5 , seed = 40 )
@@ -42,34 +58,46 @@ def four_distinct_players_mutations():
4258 except StopIteration :
4359 break
4460
61+
4562def more_players_no_mutations ():
46- players = [axl .Cooperator () for _ in range (9 )] + [axl .Defector () for _ in range (3 )]
63+ players = [axl .Cooperator () for _ in range (9 )] + [
64+ axl .Defector () for _ in range (3 )
65+ ]
4766 mp = axl .MoranProcess (players , seed = 40 )
4867 _ = mp .play ()
4968
69+
5070def more_players_mutations ():
51- players = [axl .Cooperator () for _ in range (9 )] + [axl .Defector () for _ in range (3 )]
71+ players = [axl .Cooperator () for _ in range (9 )] + [
72+ axl .Defector () for _ in range (3 )
73+ ]
5274 mp = axl .MoranProcess (players , mutation_rate = 0.5 , seed = 40 )
5375 for _ in range (50 ):
5476 try :
5577 mp .__next__ ()
5678 except StopIteration :
5779 break
5880
81+
5982def test_few_players_no_mutations (benchmark ):
6083 benchmark (few_players_no_mutations )
6184
85+
6286def test_few_players_mutations (benchmark ):
6387 benchmark (few_players_mutations )
6488
89+
6590def test_four_distinct_players_no_mutations (benchmark ):
6691 benchmark (four_distinct_players_no_mutations )
6792
93+
6894def test_four_distinct_players_mutations (benchmark ):
6995 benchmark (four_distinct_players_mutations )
7096
97+
7198def test_more_players_no_mutations (benchmark ):
7299 benchmark (more_players_no_mutations )
73100
101+
74102def test_more_players_mutations (benchmark ):
75103 benchmark (more_players_mutations )
0 commit comments