@@ -66,16 +66,18 @@ def test_bad_transitions_raise_error(self):
66
66
67
67
def test_bad_initial_state_raises_error (self ):
68
68
self .assertRaises (ValueError , SimpleFSM ,
69
- transitions = self .two_state_transition , initial_state = 5 )
69
+ transitions = self .two_state_transition ,
70
+ initial_state = 5 )
70
71
71
72
def test_state_setter_raises_error_for_bad_input (self ):
72
73
with self .assertRaises (ValueError ) as cm :
73
74
self .two_state .state = 5
74
75
error_msg = cm .exception .args [0 ]
75
- self .assertEqual (error_msg , 'state: 5 does not have values for both C and D' )
76
+ self .assertEqual (error_msg ,
77
+ 'state: 5 does not have values for both C and D' )
76
78
77
79
78
- class TestFSMPlayer (TestPlayer ):
80
+ class TestSampleFSMPlayer (TestPlayer ):
79
81
"""Test a few sample tables to make sure that the finite state machines are
80
82
working as intended."""
81
83
@@ -98,7 +100,8 @@ def test_cooperator(self):
98
100
cooperator_init_kwargs = {'transitions' : ((1 , C , 1 , C ), (1 , D , 1 , C )),
99
101
'initial_state' : 1 ,
100
102
'initial_action' : C }
101
- self .versus_test (axelrod .Alternator (), expected_actions = [(C , C ), (C , D )] * 5 ,
103
+ self .versus_test (axelrod .Alternator (),
104
+ expected_actions = [(C , C ), (C , D )] * 5 ,
102
105
init_kwargs = cooperator_init_kwargs )
103
106
104
107
def test_defector (self ):
@@ -107,7 +110,8 @@ def test_defector(self):
107
110
defector_init_kwargs = {'transitions' : ((1 , C , 1 , D ), (1 , D , 1 , D )),
108
111
'initial_state' : 1 ,
109
112
'initial_action' : D }
110
- self .versus_test (axelrod .Alternator (), expected_actions = [(D , C ), (D , D )] * 5 ,
113
+ self .versus_test (axelrod .Alternator (),
114
+ expected_actions = [(D , C ), (D , D )] * 5 ,
111
115
init_kwargs = defector_init_kwargs )
112
116
113
117
def test_tft (self ):
@@ -132,7 +136,7 @@ def test_wsls(self):
132
136
init_kwargs = wsls_init_kwargs )
133
137
134
138
135
- class TestFsmTransitions (TestPlayer ):
139
+ class TestFSMPlayer (TestPlayer ):
136
140
name = "FSM Player: ((1, 'C', 1, 'C'), (1, 'D', 1, 'D')), 1, C"
137
141
player = axelrod .FSMPlayer
138
142
@@ -169,10 +173,11 @@ def transitions_test(self, state_and_action):
169
173
expected_actions .append ((fsm_move , current_opponent_move ))
170
174
opponent_actions .append (current_opponent_move )
171
175
172
- self .verify_against_finite_state_machine (current_state = current_state ,
173
- expected_state = new_state ,
174
- last_opponent_move = last_opponent_move ,
175
- expected_move = fsm_move )
176
+ self .verify_against_finite_state_machine (
177
+ current_state = current_state ,
178
+ expected_state = new_state ,
179
+ last_opponent_move = last_opponent_move ,
180
+ expected_move = fsm_move )
176
181
177
182
self .versus_test (axelrod .MockPlayer (actions = opponent_actions ),
178
183
expected_actions = expected_actions )
@@ -219,7 +224,7 @@ def test_strategy(self):
219
224
init_kwargs = {"transitions" : transitions })
220
225
221
226
222
- class TestFortress3 (TestFsmTransitions ):
227
+ class TestFortress3 (TestFSMPlayer ):
223
228
224
229
name = "Fortress3"
225
230
player = axelrod .Fortress3
@@ -259,7 +264,7 @@ def test_incorrect_transitions(self):
259
264
self .transitions_test (state_and_actions )
260
265
261
266
262
- class TestFortress4 (TestFsmTransitions ):
267
+ class TestFortress4 (TestFSMPlayer ):
263
268
264
269
name = "Fortress4"
265
270
player = axelrod .Fortress4
@@ -299,7 +304,7 @@ def test_strategy(self):
299
304
self .transitions_test (state_and_actions )
300
305
301
306
302
- class TestPredator (TestFsmTransitions ):
307
+ class TestPredator (TestFSMPlayer ):
303
308
304
309
name = "Predator"
305
310
player = axelrod .Predator
@@ -350,7 +355,7 @@ def test_strategy(self):
350
355
self .transitions_test (state_and_actions )
351
356
352
357
353
- class TestPun1 (TestFsmTransitions ):
358
+ class TestPun1 (TestFSMPlayer ):
354
359
355
360
name = "Pun1"
356
361
player = axelrod .Pun1
@@ -380,7 +385,7 @@ def test_strategy(self):
380
385
self .transitions_test (state_and_actions )
381
386
382
387
383
- class TestRaider (TestFsmTransitions ):
388
+ class TestRaider (TestFSMPlayer ):
384
389
385
390
name = "Raider"
386
391
player = axelrod .Raider
@@ -420,7 +425,7 @@ def test_strategy(self):
420
425
self .transitions_test (state_and_actions )
421
426
422
427
423
- class TestRipoff (TestFsmTransitions ):
428
+ class TestRipoff (TestFSMPlayer ):
424
429
425
430
name = "Ripoff"
426
431
player = axelrod .Ripoff
@@ -455,7 +460,7 @@ def test_strategy(self):
455
460
self .transitions_test (state_and_actions )
456
461
457
462
458
- class TestSolutionB1 (TestFsmTransitions ):
463
+ class TestSolutionB1 (TestFSMPlayer ):
459
464
460
465
name = "SolutionB1"
461
466
player = axelrod .SolutionB1
@@ -488,7 +493,7 @@ def test_strategy(self):
488
493
self .transitions_test (state_and_actions )
489
494
490
495
491
- class TestSolutionB5 (TestFsmTransitions ):
496
+ class TestSolutionB5 (TestFSMPlayer ):
492
497
493
498
name = "SolutionB5"
494
499
player = axelrod .SolutionB5
@@ -533,7 +538,7 @@ def test_strategy(self):
533
538
self .transitions_test (state_and_actions )
534
539
535
540
536
- class TestThumper (TestFsmTransitions ):
541
+ class TestThumper (TestFSMPlayer ):
537
542
538
543
name = "Thumper"
539
544
player = axelrod .Thumper
@@ -563,7 +568,7 @@ def test_strategy(self):
563
568
self .transitions_test (state_and_actions )
564
569
565
570
566
- class TestEvolvedFSM4 (TestFsmTransitions ):
571
+ class TestEvolvedFSM4 (TestFSMPlayer ):
567
572
568
573
name = "Evolved FSM 4"
569
574
player = axelrod .EvolvedFSM4
@@ -601,7 +606,7 @@ def test_strategy(self):
601
606
self .transitions_test (state_and_actions )
602
607
603
608
604
- class TestEvolvedFSM16 (TestFsmTransitions ):
609
+ class TestEvolvedFSM16 (TestFSMPlayer ):
605
610
606
611
name = "Evolved FSM 16"
607
612
player = axelrod .EvolvedFSM16
@@ -693,7 +698,7 @@ def test_strategy(self):
693
698
self .transitions_test (state_and_actions )
694
699
695
700
696
- class TestEvolvedFSM16Noise05 (TestFsmTransitions ):
701
+ class TestEvolvedFSM16Noise05 (TestFSMPlayer ):
697
702
698
703
name = "Evolved FSM 16 Noise 05"
699
704
player = axelrod .EvolvedFSM16Noise05
@@ -780,3 +785,60 @@ def test_strategy(self):
780
785
# finished 0, 1, 2, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15
781
786
state_and_actions = to_state_eleven + [(11 , C ), (14 , D )] + [(13 , C )] * 3
782
787
self .transitions_test (state_and_actions )
788
+
789
+
790
+ class TestTF1 (TestFSMPlayer ):
791
+ name = "TF1"
792
+ player = axelrod .TF1
793
+ expected_classifier = {
794
+ 'memory_depth' : float ('inf' ),
795
+ 'stochastic' : False ,
796
+ 'makes_use_of' : set (),
797
+ 'long_run_time' : False ,
798
+ 'inspects_source' : False ,
799
+ 'manipulates_source' : False ,
800
+ 'manipulates_state' : False
801
+ }
802
+
803
+ def test_strategy (self ):
804
+ self .first_play_test (C )
805
+ actions = [(C , C ), (C , D ), (D , C ), (D , D ), (D , C )]
806
+ self .versus_test (axelrod .Alternator (), expected_actions = actions )
807
+
808
+
809
+ class TestTF2 (TestFSMPlayer ):
810
+ name = "TF2"
811
+ player = axelrod .TF2
812
+ expected_classifier = {
813
+ 'memory_depth' : float ('inf' ),
814
+ 'stochastic' : False ,
815
+ 'makes_use_of' : set (),
816
+ 'long_run_time' : False ,
817
+ 'inspects_source' : False ,
818
+ 'manipulates_source' : False ,
819
+ 'manipulates_state' : False
820
+ }
821
+
822
+ def test_strategy (self ):
823
+ self .first_play_test (C )
824
+ actions = [(C , C ), (D , D ), (D , C ), (C , D ), (D , C )]
825
+ self .versus_test (axelrod .Alternator (), expected_actions = actions )
826
+
827
+
828
+ class TestTF3 (TestFSMPlayer ):
829
+ name = "TF3"
830
+ player = axelrod .TF3
831
+ expected_classifier = {
832
+ 'memory_depth' : float ('inf' ),
833
+ 'stochastic' : False ,
834
+ 'makes_use_of' : set (),
835
+ 'long_run_time' : False ,
836
+ 'inspects_source' : False ,
837
+ 'manipulates_source' : False ,
838
+ 'manipulates_state' : False
839
+ }
840
+
841
+ def test_strategy (self ):
842
+ self .first_play_test (C )
843
+ actions = [(C , C ), (C , D ), (C , C ), (D , D ), (D , C )]
844
+ self .versus_test (axelrod .Alternator (), expected_actions = actions )
0 commit comments