def test_strategy(self): """ Starts by cooperating """ P1 = axelrod.TwoTitsForTat() P2 = axelrod.Player() self.assertEqual(P1.strategy(P2), 'C')
def tscizzle_strategies(): """The list of strategies used in @tscizzle's Morality Metrics paper.""" strategies = [ axelrod.Cooperator(), axelrod.Defector(), axelrod.Eatherley(), axelrod.Champion(), axelrod.GTFT(p=0.1), axelrod.GTFT(p=0.3), axelrod.GoByMajority(soft=True), axelrod.GoByMajority(soft=False), axelrod.TitFor2Tats(), axelrod.Random(0.8), axelrod.Random(0.5), axelrod.Random(0.2), axelrod.WinStayLoseShift(), # Pavlov axelrod.TitForTat(), axelrod.TwoTitsForTat(), axelrod.Grudger(), # Friedman axelrod.Tester(), axelrod.SuspiciousTitForTat(), axelrod.Joss(0.9), axelrod.Joss(0.7), ] return strategies
def test_effect_of_strategy(self): """ Will defect only when last two turns of opponent were defections. """ P1 = axelrod.TwoTitsForTat() P2 = axelrod.Player() P1.history = ['C', 'C'] P2.history = ['D', 'D'] self.assertEqual(P1.strategy(P2), 'D') P1.history = ['C', 'C', 'D'] P2.history = ['D', 'D', 'C'] self.assertEqual(P1.strategy(P2), 'D') P1.history = ['C', 'C', 'D', 'D'] P2.history = ['D', 'D', 'C', 'C'] self.assertEqual(P1.strategy(P2), 'C')
def main(): strategies = [ axelrod.Cooperator(), axelrod.Defector(), axelrod.Random(0.4), axelrod.Random(0.5), axelrod.Random(0.9), axelrod.Alternator(), axelrod.TitForTat(), axelrod.GTFT(), axelrod.WinStayLoseShift(), axelrod.ZDGTFT2(), axelrod.ZDExtort2(), axelrod.TitFor2Tats(), axelrod.TwoTitsForTat(), axelrod.CyclerCCD(), axelrod.CyclerCCCD(), axelrod.CyclerCCCCCD(), axelrod.HardTitForTat(), axelrod.AntiCycler(), axelrod.Grudger() ] for opponent in strategies: data_dict, test_results, estimate = infer_depth(opponent) print opponent print "-" * len(str(opponent)) print "Collected Data" print_dict(data_dict) C_count = sum(v[0] for (k, v) in data_dict.items()) D_count = sum(v[1] for (k, v) in data_dict.items()) print "C count, D count: %s, %s" % (C_count, D_count) print "\nFisher Exact Tests" print_dict(test_results) print "\nEstimated Memory One Probabilities" print_dict(estimate) print
def test_stochastic(self): self.assertFalse(axelrod.TwoTitsForTat().stochastic)
def test_representation(self): P1 = axelrod.TwoTitsForTat() self.assertEqual(str(P1), 'Two T**s For Tat')