コード例 #1
0
 def test_rounds(self):
     self.versus_test(
         axl.FoolMeOnce(),
         axl.Bully(),
         [C, C, D, D, D, D],
         [D, D, D, C, C, C],
     )
コード例 #2
0
 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])
コード例 #3
0
def tft_strats():
    strategies = [
        axelrod.TitForTat(),
        axelrod.Alternator(),
        axelrod.CyclerCCD(),
        axelrod.CyclerCCCD(),
        axelrod.CyclerCCCCCD(),
        axelrod.AntiCycler(),
        axelrod.WinStayLoseShift(),
        axelrod.FoolMeOnce()
    ]
    return strategies
コード例 #4
0
 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')
コード例 #5
0
 def test_rounds(self):
     self.versus_test(axelrod.FoolMeOnce(), axelrod.SuspiciousTitForTat(),
                      [C] * 9, [D] + [C] * 8)
コード例 #6
0
 def test_initial(self):
     P1 = axelrod.FoolMeOnce()
     P2 = axelrod.Player()
     self.assertEqual(P1.strategy(P2), P1._initial)