Esempio n. 1
0
 def test_effect_of_strategy(self):
     """If opponent has defected more than 10 percent of the time, defect."""
     P1 = axelrod.Retaliate()
     P2 = axelrod.Player()
     self.responses_test([C] * 4, [C] * 4, [C])
     self.responses_test([C, C, C, C, D], [C, C, C, D, C], [D])
     self.responses_test([C] * 6, [C] * 5 + [D], [D])
Esempio n. 2
0
 def test_initial_strategy(self):
     """
     Starts by cooperating
     """
     P1 = axelrod.Retaliate()
     P2 = axelrod.Player()
     self.assertEqual(P1.strategy(P2), 'C')
Esempio n. 3
0
 def test_strategy(self):
     # Starts by cooperating.
     self.first_play_test(C)
     # If opponent has defected more than 10 percent of the time, defect.
     P1 = axelrod.Retaliate()
     P2 = axelrod.Player()
     self.responses_test([C], [C] * 4, [C] * 4)
     self.responses_test([D], [C, C, C, C, D], [C, C, C, D, C])
     self.responses_test([D], [C] * 6, [C] * 5 + [D])
Esempio n. 4
0
 def test_effect_of_strategy(self):
     """If opponent has defected more than 10 percent of the time, defect."""
     P1 = axelrod.Retaliate()
     P2 = axelrod.Player()
     P1.history = ['C', 'C', 'C', 'C']
     P2.history = ['C', 'C', 'C', 'C']
     self.assertEqual(P1.strategy(P2), 'C')
     P1.history = ['C', 'C', 'C', 'C', 'D']
     P2.history = ['C', 'C', 'C', 'D', 'C']
     self.assertEqual(P1.strategy(P2), 'D')
     P1.history = ['C', 'C', 'C', 'C', 'C', 'C']
     P2.history = ['C', 'C', 'C', 'C', 'C', 'D']
     self.assertEqual(P1.strategy(P2), 'D')
Esempio n. 5
0
 def test_stochastic(self):
     self.assertFalse(axelrod.Retaliate().stochastic)
Esempio n. 6
0
 def test_representation(self):
     P1 = axelrod.Retaliate()
     self.assertEqual(str(P1), 'Retaliate')