def test_wsls(self): """Tests that the player defined by the table for TFT is in fact WSLS (also known as Pavlov.""" t_C = [[1, 0], [0, 1]] t_D = [[0, 1], [1, 0]] p = [1, 0] player = axelrod.HMMPlayer(transitions_C=t_C, transitions_D=t_D, emission_probabilities=p, initial_state=0, initial_action=C) self.assertFalse(player.is_stochastic()) self.assertFalse(player.classifier['stochastic']) opponent = axelrod.Alternator() for i in range(6): player.play(opponent) self.assertEqual(opponent.history, [C, D] * 3) self.assertEqual(player.history, [C, C, D, D, C, C])
def test_defector(self): """Tests that the player defined by the table for Defector is in fact Defector.""" t_C = [[1]] t_D = [[1]] p = [0] player = axelrod.HMMPlayer(transitions_C=t_C, transitions_D=t_D, emission_probabilities=p, initial_state=0, initial_action=D) self.assertFalse(player.is_stochastic()) self.assertFalse(player.classifier['stochastic']) opponent = axelrod.Alternator() for i in range(6): player.play(opponent) self.assertEqual(opponent.history, [C, D] * 3) self.assertEqual(player.history, [D] * 6)
def test_tft(self): """Tests that the player defined by the table for TFT is in fact TFT.""" t_C = [[1, 0], [1, 0]] t_D = [[0, 1], [0, 1]] p = [1, 0] player = axelrod.HMMPlayer(t_C, t_D, p, initial_state=0, initial_action=C) self.assertFalse(player.is_stochastic()) self.assertFalse(player.classifier['stochastic']) opponent = axelrod.Alternator() for i in range(6): player.play(opponent) self.assertEqual(opponent.history, [C, D] * 3) self.assertEqual(player.history, [C, C, D, C, D, C])
def test_wsls(self): """Tests that the player defined by the table for WSLS is in fact WSLS (also known as Pavlov).""" t_C = [[1, 0], [0, 1]] t_D = [[0, 1], [1, 0]] p = [1, 0] player = axl.HMMPlayer( transitions_C=t_C, transitions_D=t_D, emission_probabilities=p, initial_state=0, initial_action=C, ) self.assertFalse(player.is_stochastic()) self.assertFalse(axl.Classifiers["stochastic"](player)) opponent = axl.Alternator() match = axl.Match((player, opponent), turns=6) match.play() self.assertEqual(opponent.history, [C, D] * 3) self.assertEqual(player.history, [C, C, D, D, C, C])
def test_defector(self): """Tests that the player defined by the table for Defector is in fact Defector.""" t_C = [[1]] t_D = [[1]] p = [0] player = axl.HMMPlayer( transitions_C=t_C, transitions_D=t_D, emission_probabilities=p, initial_state=0, initial_action=D, ) self.assertFalse(player.is_stochastic()) self.assertFalse(axl.Classifiers["stochastic"](player)) opponent = axl.Alternator() match = axl.Match((player, opponent), turns=6) match.play() self.assertEqual(opponent.history, [C, D] * 3) self.assertEqual(player.history, [D] * 6)
def test_tft(self): """Tests that the player defined by the table for TFT is in fact TFT.""" t_C = [[1, 0], [1, 0]] t_D = [[0, 1], [0, 1]] p = [1, 0] player = axl.HMMPlayer( transitions_C=t_C, transitions_D=t_D, emission_probabilities=p, initial_state=0, initial_action=C, ) self.assertFalse(player.is_stochastic()) self.assertFalse(axl.Classifiers["stochastic"](player)) opponent = axl.Alternator() for i in range(6): player.play(opponent) self.assertEqual(opponent.history, [C, D] * 3) self.assertEqual(player.history, [C, C, D, C, D, C])