3
3
import axelrod
4
4
import unittest
5
5
from .test_player import TestPlayer
6
- from axelrod import dbs
6
+ from axelrod . strategies import dbs
7
7
8
8
C , D = axelrod .Actions .C , axelrod .Actions .D
9
9
@@ -15,18 +15,18 @@ class TestNode(unittest.TestCase):
15
15
node = dbs .Node ()
16
16
17
17
def test_get_siblings (self ):
18
- with self .assertRaises (NotImplementedError ) as context :
18
+ with self .assertRaises (NotImplementedError ):
19
19
self .node .get_siblings ()
20
20
21
21
def test_is_stochastic (self ):
22
- with self .assertRaises (NotImplementedError ) as context :
22
+ with self .assertRaises (NotImplementedError ):
23
23
self .node .is_stochastic ()
24
24
25
25
26
26
class TestTreeSearch (unittest .TestCase ):
27
27
"""
28
28
A set of tests for the tree-search functions.
29
- We test the answers of both minimax_tree_search and MoveGen
29
+ We test the answers of both minimax_tree_search and move_gen
30
30
functions, against a set of classic policies (the answer being the
31
31
best move to play for the next turn, considering an income
32
32
position (C, C), (C, D), (D, C) or (D, D))
@@ -36,7 +36,7 @@ def setUp(self):
36
36
"""
37
37
Initialization for tests.
38
38
"""
39
- # For each test, we check the answer againt each possible
39
+ # For each test, we check the answer against each possible
40
40
# inputs, that are in self.input_pos
41
41
self .input_pos = [(C , C ), (C , D ), (D , C ), (D , D )]
42
42
# We define the policies against which we are going to test
@@ -62,14 +62,14 @@ def test_minimaxTreeSearch_cooperator(self):
62
62
self .cooperator_policy , max_depth = 5 )
63
63
self .assertEqual (values .index (max (values )),out )
64
64
65
- def test_MoveGen_cooperator (self ):
65
+ def test_move_gen_cooperator (self ):
66
66
"""
67
- Tests the MoveGen function when playing against a
67
+ Tests the move_gen function when playing against a
68
68
Cooperator player.
69
69
"""
70
70
expected_output = [D , D , D , D ]
71
71
for inp , out in zip (self .input_pos , expected_output ):
72
- out_move = dbs .MoveGen (inp , self .cooperator_policy ,
72
+ out_move = dbs .move_gen (inp , self .cooperator_policy ,
73
73
depth_search_tree = 5 )
74
74
self .assertEqual (out_move , out )
75
75
@@ -86,14 +86,14 @@ def test_minimaxTreeSearch_defector(self):
86
86
self .defector_policy , max_depth = 5 )
87
87
self .assertEqual (values .index (max (values )),out )
88
88
89
- def test_MoveGen_defector (self ):
89
+ def test_move_gen_defector (self ):
90
90
"""
91
- Tests the MoveGen function when playing against a
91
+ Tests the move_gen function when playing against a
92
92
Defector player.
93
93
"""
94
94
expected_output = [D , D , D , D ]
95
95
for inp , out in zip (self .input_pos , expected_output ):
96
- out_move = dbs .MoveGen (inp , self .defector_policy ,
96
+ out_move = dbs .move_gen (inp , self .defector_policy ,
97
97
depth_search_tree = 5 )
98
98
self .assertEqual (out_move , out )
99
99
@@ -123,14 +123,14 @@ def test_last_node_titForTat(self):
123
123
self .titForTat_policy , max_depth = 1 )
124
124
self .assertEqual (values .index (max (values )),out )
125
125
126
- def test_MoveGen_titForTat (self ):
126
+ def test_move_gen_titForTat (self ):
127
127
"""
128
- Tests the MoveGen function when playing against a
128
+ Tests the move_gen function when playing against a
129
129
TitForTat player.
130
130
"""
131
131
expected_output = [C , C , C , C ]
132
132
for inp , out in zip (self .input_pos , expected_output ):
133
- out_move = dbs .MoveGen (inp , self .titForTat_policy ,
133
+ out_move = dbs .move_gen (inp , self .titForTat_policy ,
134
134
depth_search_tree = 5 )
135
135
self .assertEqual (out_move , out )
136
136
@@ -147,14 +147,14 @@ def test_minimaxTreeSearch_alternator(self):
147
147
self .alternator_policy , max_depth = 5 )
148
148
self .assertEqual (values .index (max (values )),out )
149
149
150
- def test_MoveGen_alternator (self ):
150
+ def test_move_gen_alternator (self ):
151
151
"""
152
- Tests the MoveGen function when playing against an
152
+ Tests the move_gen function when playing against an
153
153
Alternator player.
154
154
"""
155
155
expected_output = [D , D , D , D ]
156
156
for inp , out in zip (self .input_pos , expected_output ):
157
- out_move = dbs .MoveGen (inp , self .random_policy , depth_search_tree = 5 )
157
+ out_move = dbs .move_gen (inp , self .random_policy , depth_search_tree = 5 )
158
158
self .assertEqual (out_move , out )
159
159
160
160
def test_minimaxTreeSearch_random (self ):
@@ -170,14 +170,14 @@ def test_minimaxTreeSearch_random(self):
170
170
self .random_policy , max_depth = 5 )
171
171
self .assertEqual (values .index (max (values )),out )
172
172
173
- def test_MoveGen_random (self ):
173
+ def test_move_gen_random (self ):
174
174
"""
175
- Tests the MoveGen function when playing against a
175
+ Tests the move_gen function when playing against a
176
176
Random player.
177
177
"""
178
178
expected_output = [D , D , D , D ]
179
179
for inp , out in zip (self .input_pos , expected_output ):
180
- out_move = dbs .MoveGen (inp , self .random_policy , depth_search_tree = 5 )
180
+ out_move = dbs .move_gen (inp , self .random_policy , depth_search_tree = 5 )
181
181
self .assertEqual (out_move , out )
182
182
183
183
def test_minimaxTreeSearch_grudger (self ):
@@ -194,14 +194,14 @@ def test_minimaxTreeSearch_grudger(self):
194
194
self .grudger_policy , max_depth = 5 )
195
195
self .assertEqual (values .index (max (values )),out )
196
196
197
- def test_MoveGen_grudger (self ):
197
+ def test_move_gen_grudger (self ):
198
198
"""
199
- Tests the MoveGen function when playing against a
199
+ Tests the move_gen function when playing against a
200
200
Grudger player.
201
201
"""
202
202
expected_output = [C , D , D , D ]
203
203
for inp , out in zip (self .input_pos , expected_output ):
204
- out_move = dbs .MoveGen (inp ,
204
+ out_move = dbs .move_gen (inp ,
205
205
self .grudger_policy , depth_search_tree = 5 )
206
206
self .assertEqual (out_move , out )
207
207
0 commit comments