def test_rounds(self): self.versus_test( axl.FoolMeOnce(), axl.Bully(), [C, C, D, D, D, D], [D, D, D, C, C, C], )
def test_strategy(self): """ If opponent defects more than once, defect forever """ P1 = axelrod.FoolMeOnce() P2 = axelrod.Defector() self.responses_test([C], [D], [C]) self.responses_test([C, C], [D, D], [D]) self.responses_test([C, C], [D, C], [C]) self.responses_test([C, C, C], [D, D, D], [D])
def tft_strats(): strategies = [ axelrod.TitForTat(), axelrod.Alternator(), axelrod.CyclerCCD(), axelrod.CyclerCCCD(), axelrod.CyclerCCCCCD(), axelrod.AntiCycler(), axelrod.WinStayLoseShift(), axelrod.FoolMeOnce() ] return strategies
def test_strategy(self): """ If opponent defects at any point then the player will defect forever """ P1 = axelrod.FoolMeOnce() P2 = axelrod.Defector() P1.history = ['C'] P2.history = ['D'] self.assertEqual(P1.strategy(P2), 'C') P1.history = ['C'] P2.history = ['D'] self.assertEqual(P1.strategy(P2), 'D')
def test_rounds(self): self.versus_test(axelrod.FoolMeOnce(), axelrod.SuspiciousTitForTat(), [C] * 9, [D] + [C] * 8)
def test_initial(self): P1 = axelrod.FoolMeOnce() P2 = axelrod.Player() self.assertEqual(P1.strategy(P2), P1._initial)