def test_strategies_without_countermeasures_return_their_strategy(self): tft = axelrod.TitForTat() inspector = axelrod.Alternator() tft.play(inspector) self.assertEqual(tft.history, [C]) self.assertEqual(inspect_strategy(inspector=inspector, opponent=tft), C) tft.play(inspector) self.assertEqual(tft.history, [C, C]) self.assertEqual(inspect_strategy(inspector=inspector, opponent=tft), D) self.assertEqual(tft.strategy(inspector), D)
def test_strategies_without_countermeasures_return_their_strategy(self): tft = axelrod.TitForTat() inspector = axelrod.Alternator() tft.play(inspector) self.assertEqual(tft.history, [C]) self.assertEqual(inspect_strategy(inspector=inspector, opponent=tft), C) tft.play(inspector) self.assertEqual(tft.history, [C, C]) self.assertEqual(inspect_strategy(inspector=inspector, opponent=tft), D) self.assertEqual(tft.strategy(inspector), D)
def test_strategies_without_countermeasures_return_their_strategy(self): tft = axl.TitForTat() inspector = axl.Alternator() match = axl.Match((tft, inspector), turns=1) match.play() self.assertEqual(tft.history, [C]) self.assertEqual(inspect_strategy(inspector=inspector, opponent=tft), C) match = axl.Match((tft, inspector), turns=2) match.play() self.assertEqual(tft.history, [C, C]) self.assertEqual(inspect_strategy(inspector=inspector, opponent=tft), D) self.assertEqual(tft.strategy(inspector), D)
def test_strategies_with_countermeasures_return_their_countermeasures(self): d_geller = axelrod.GellerDefector() inspector = axelrod.Cooperator() d_geller.play(inspector) self.assertEqual(inspect_strategy(inspector=inspector, opponent=d_geller), D) self.assertEqual(d_geller.strategy(inspector), C)
def test_strategies_with_countermeasures_return_their_countermeasures(self): d_geller = axelrod.GellerDefector() inspector = axelrod.Cooperator() d_geller.play(inspector) self.assertEqual(inspect_strategy(inspector=inspector, opponent=d_geller), D) self.assertEqual(d_geller.strategy(inspector), C)
def strategy(self, opponent: Player) -> Action: """ Look at what the opponent will play in the next round and choose a strategy that gives the least jail time, which is is equivalent to playing the same strategy as that which the opponent will play. """ return inspect_strategy(self, opponent)
def strategy(self, opponent: Player) -> Action: """ Look at what the opponent will play in the next round and choose a strategy that gives the least jail time, which is is equivalent to playing the same strategy as that which the opponent will play. """ return inspect_strategy(self, opponent)
def test_strategies_with_countermeasures_return_their_countermeasures( self): d_geller = axl.GellerDefector() inspector = axl.Cooperator() match = axl.Match((d_geller, inspector), turns=1) match.play() self.assertEqual( inspect_strategy(inspector=inspector, opponent=d_geller), D) self.assertEqual(d_geller.strategy(inspector), C)
def strategy(self, opponent: Player) -> Action: """Will read the mind of the opponent and play the opponent's strategy. """ return inspect_strategy(self, opponent)