def test_meta_inclusion(self): self.assertTrue(str(axl.MetaMajority()) in str_reps(axl.strategies)) self.assertTrue(str(axl.MetaHunter()) in str_reps(axl.strategies)) self.assertFalse( str(axl.MetaHunter()) in str_reps(axl.long_run_time_strategies) )
def test_strategy(self): P1 = axl.MetaMajority() P2 = axl.Player() # With more cooperators on the team than defectors, we should cooperate. P1.team = [axl.Cooperator(), axl.Cooperator(), axl.Defector()] self.assertEqual(P1.strategy(P2), C) # With more defectors, we should defect. P1.team = [axl.Cooperator(), axl.Defector(), axl.Defector()] self.assertEqual(P1.strategy(P2), D)