def test_strategy(self): for action in [C, D]: m = MockPlayer(actions=[action]) p2 = Player() self.assertEqual(action, m.strategy(p2)) actions = [C, C, D, D, C, C] m = MockPlayer(actions=actions) p2 = Player() for action in actions: self.assertEqual(action, m.strategy(p2))
def test_strategy(self): for action in [C, D]: m = MockPlayer(actions=[action]) p2 = axelrod.Player() self.assertEqual(action, m.strategy(p2)) actions = [C, C, D, D, C, C] m = MockPlayer(actions=actions) p2 = axelrod.Player() for action in actions: self.assertEqual(action, m.strategy(p2))
def test_history(self): t = TestOpponent() m1 = MockPlayer([C], history=[C] * 10) self.assertEqual(m1.actions[0], C) self.assertEqual(m1.history, [C] * 10) self.assertEqual(m1.cooperations, 10) self.assertEqual(m1.defections, 0) self.assertEqual(m1.strategy(t), C) m2 = MockPlayer([D], history=[D] * 10) self.assertEqual(m2.actions[0], D) self.assertEqual(m2.history, [D] * 10) self.assertEqual(m2.cooperations, 0) self.assertEqual(m2.defections, 10) self.assertEqual(m2.strategy(t), D)
def test_strategy(self): for move in [C, D]: m = MockPlayer(axelrod.Player(), move) p2 = axelrod.Player() self.assertEqual(move, m.strategy(p2))