示例#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])
示例#2
0
 def test_initial_strategy(self):
     """
     Starts by cooperating
     """
     P1 = axelrod.Retaliate()
     P2 = axelrod.Player()
     self.assertEqual(P1.strategy(P2), 'C')
示例#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])
示例#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')
示例#5
0
 def test_stochastic(self):
     self.assertFalse(axelrod.Retaliate().stochastic)
示例#6
0
 def test_representation(self):
     P1 = axelrod.Retaliate()
     self.assertEqual(str(P1), 'Retaliate')