|
1 | 1 | import axelrod as axl |
2 | 2 | from axelrod import Action |
3 | | -from axelrod.tests.strategies.test_player import TestPlayer |
4 | 3 | from axelrod.strategies.momentum import Momentum |
| 4 | +from axelrod.tests.strategies.test_player import TestPlayer |
5 | 5 |
|
6 | 6 | C, D = Action.C, Action.D |
7 | 7 |
|
| 8 | + |
8 | 9 | class TestMomentum(TestPlayer): |
9 | 10 | name = "Momentum" |
10 | 11 | player = Momentum |
@@ -32,68 +33,56 @@ def test_strategy(self): |
32 | 33 | self.versus_test( |
33 | 34 | axl.MockPlayer(actions=[C]), |
34 | 35 | expected_actions=actions, |
35 | | - init_kwargs={"alpha": 0.5, |
36 | | - "threshold": 0.5 |
37 | | - }, |
38 | | - attrs={"momentum": 1.0} |
| 36 | + init_kwargs={"alpha": 0.5, "threshold": 0.5}, |
| 37 | + attrs={"momentum": 1.0}, |
39 | 38 | ) |
40 | | - |
| 39 | + |
41 | 40 | actions = [(C, D), (C, D), (D, D)] |
42 | 41 | self.versus_test( |
43 | 42 | axl.MockPlayer(actions=[D]), |
44 | 43 | expected_actions=actions, |
45 | | - init_kwargs={"alpha": 0.5, |
46 | | - "threshold": 0.5 |
47 | | - }, |
48 | | - attrs={"momentum": 0.25} |
| 44 | + init_kwargs={"alpha": 0.5, "threshold": 0.5}, |
| 45 | + attrs={"momentum": 0.25}, |
49 | 46 | ) |
50 | | - |
| 47 | + |
51 | 48 | def test_vs_alternator(self): |
52 | 49 | actions = [(C, C), (C, D), (C, C), (C, D), (D, C)] |
53 | | - self.versus_test(axl.Alternator(), |
54 | | - expected_actions=actions, |
55 | | - init_kwargs={"alpha": 0.5, |
56 | | - "threshold": 0.5 |
57 | | - }, |
| 50 | + self.versus_test( |
| 51 | + axl.Alternator(), |
| 52 | + expected_actions=actions, |
| 53 | + init_kwargs={"alpha": 0.5, "threshold": 0.5}, |
58 | 54 | ) |
59 | 55 |
|
60 | 56 | def test_vs_cooperator(self): |
61 | 57 | actions = [(C, C), (C, C), (C, C), (C, C), (C, C)] |
62 | | - self.versus_test(axl.Cooperator(), |
63 | | - expected_actions=actions, |
64 | | - init_kwargs={"alpha": 0.5, |
65 | | - "threshold": 0.5 |
66 | | - }, |
| 58 | + self.versus_test( |
| 59 | + axl.Cooperator(), |
| 60 | + expected_actions=actions, |
| 61 | + init_kwargs={"alpha": 0.5, "threshold": 0.5}, |
67 | 62 | ) |
68 | 63 |
|
69 | 64 | def test_vs_defector(self): |
70 | 65 | actions = [(C, D), (C, D), (D, D), (D, D), (D, D)] |
71 | | - self.versus_test(axl.Defector(), |
72 | | - expected_actions=actions, |
73 | | - init_kwargs={"alpha": 0.5, |
74 | | - "threshold": 0.5 |
75 | | - }, |
| 66 | + self.versus_test( |
| 67 | + axl.Defector(), |
| 68 | + expected_actions=actions, |
| 69 | + init_kwargs={"alpha": 0.5, "threshold": 0.5}, |
76 | 70 | ) |
77 | 71 |
|
78 | 72 | def test_vs_random(self): |
79 | | - # We can also test against random strategies |
80 | 73 | actions = [(C, D), (C, C), (C, C), (C, D), (D, D)] |
81 | | - self.versus_test(axl.Random(), |
82 | | - expected_actions=actions, |
83 | | - seed=17, |
84 | | - init_kwargs={"alpha": 0.5, |
85 | | - "threshold": 0.5 |
86 | | - }, |
| 74 | + self.versus_test( |
| 75 | + axl.Random(), |
| 76 | + expected_actions=actions, |
| 77 | + seed=17, |
| 78 | + init_kwargs={"alpha": 0.5, "threshold": 0.5}, |
87 | 79 | ) |
88 | 80 |
|
89 | 81 | def test_vs_random2(self): |
90 | 82 | actions = [(C, C), (C, C), (C, C), (C, C)] |
91 | | - self.versus_test(axl.Random(), |
92 | | - expected_actions=actions, |
93 | | - seed=3, |
94 | | - init_kwargs={"alpha": 0.5, |
95 | | - "threshold": 0.5 |
96 | | - }, |
| 83 | + self.versus_test( |
| 84 | + axl.Random(), |
| 85 | + expected_actions=actions, |
| 86 | + seed=3, |
| 87 | + init_kwargs={"alpha": 0.5, "threshold": 0.5}, |
97 | 88 | ) |
98 | | - |
99 | | - |
0 commit comments