22
33import axelrod as axl
44
5- from .test_player import TestPlayer
5+ from .test_player import TestPlayer , TestMatch
66
77C , D = axl .Action .C , axl .Action .D
88
@@ -21,8 +21,62 @@ class TestEpsilonGreedy(TestPlayer):
2121 "manipulates_state" : False ,
2222 }
2323
24+ def test_deterministic (self ):
25+ # cases where epsilon = 0
26+ actions = [(C , C ), (C , C ), (C , C )]
27+ self .versus_test (axl .Cooperator (),
28+ expected_actions = actions ,
29+ init_kwargs = {"epsilon" : 0 , "init_c_reward" : 0 , "init_d_reward" : - 1 },
30+ attrs = {"_rewards" : {C : 3 , D : - 1 }})
31+
32+ actions = [(D , D ), (D , D ), (D , D )]
33+ self .versus_test (axl .Defector (),
34+ expected_actions = actions ,
35+ init_kwargs = {"epsilon" : 0 , "init_c_reward" : - 1 , "init_d_reward" : 0 },
36+ attrs = {"_rewards" : {C : - 1 , D : 1 }})
37+
38+ # actions = [(D, C), (D, D)]
39+ # self.versus_test(axl.TitForTat(),
40+ # expected_actions=actions,
41+ # init_kwargs={"epsilon": 0, "init_c_reward": 3.2, "init_d_reward": 4},
42+ # attrs={"_rewards": {C: 3.2, D: 9}})
43+
2444 def test_random (self ):
25- """Test that strategy is randomly picked (not affected by history)."""
45+ # case where epsilon = 1
2646 opponent = axl .MockPlayer ()
27- actions = [(C , C ), (C , D ), (C , D ), (C , C ), (C , D )]
28- self .versus_test (opponent , expected_actions = actions , seed = 0 , init_kwargs = {"epsilon" : 1 })
47+ actions = [(C , C ), (D , C ), (D , C ), (C , C )]
48+ self .versus_test (opponent , expected_actions = actions , init_kwargs = {"epsilon" : 1 }, seed = 5 )
49+
50+
51+ # def versus_test(
52+ # self,
53+ # opponent,
54+ # expected_actions,
55+ # turns=None,
56+ # noise=None,
57+ # seed=None,
58+ # match_attributes=None,
59+ # attrs=None,
60+ # init_kwargs=None,
61+ # ):
62+ #
63+ # if init_kwargs is None:
64+ # init_kwargs = dict()
65+ #
66+ # player = self.player(**init_kwargs)
67+ #
68+ # test_match = TestMatch()
69+ # seed = test_match.search_seeds(
70+ # player,
71+ # opponent,
72+ # [x for (x, y) in expected_actions],
73+ # [y for (x, y) in expected_actions],
74+ # turns=turns,
75+ # noise=noise,
76+ # seed=seed,
77+ # attrs=attrs,
78+ # match_attributes=match_attributes,
79+ # )
80+ # self.assertIsNotNone(seed)
81+ # print(seed)
82+ #
0 commit comments