Exemplo n.º 1
0
 def test_strategy_against_lookerup_players(self):
     """
     Regression test for a bug discussed in
     https://github.com/Axelrod-Python/Axelrod/issues/1185
     """
     self.versus_test(axl.EvolvedLookerUp1_1_1(),
                      expected_actions=[(C, C), (C, C)])
     self.versus_test(axl.EvolvedLookerUp2_2_2(),
                      expected_actions=[(C, C), (C, C)])
Exemplo n.º 2
0
 def test_vs(self):
     self.versus_test(axelrod.EvolvedLookerUp2_2_2(), axelrod.Alternator(),
                      [C, C, C, D, D, D], [C, D, C, D, C, D])
Exemplo n.º 3
0
 def test_vs(self):
     outcomes = zip()
     self.versus_test(axelrod.EvolvedLookerUp2_2_2(), axelrod.TitForTat(),
                      [C] * 10, [C] * 10)
Exemplo n.º 4
0
 def test_vs(self):
     self.versus_test(axelrod.EvolvedLookerUp2_2_2(), axelrod.Cooperator(),
                      [C] * 10, [C] * 10)
Exemplo n.º 5
0
 def test_vs(self):
     self.versus_test(axelrod.EvolvedLookerUp2_2_2(), axelrod.Defector(),
                      [C, C, D], [D, D, D])
Exemplo n.º 6
0
                #  return D if previous 3 times of opponent are C then return C
                if len(self.history) > 2:
                    if list(opponent.history)[-2] == D and list(opponent.history)[-1] == D:
                        return D
                    elif list(opponent.history)[-3:len(self.history)] ==[C, C, C]:
                        return C
                return C
        return C

#==============================================================================
# Tournament Running
#==============================================================================

# Store strategies that we need to test for the tornament into players
players = [IDoWhatIWant(), axl.Random(), axl.TitForTat(), axl.Defector(), axl.BackStabber(),
           axl.FirstByDavis(), axl.Grudger(), axl.Gambler(), axl.EvolvedLookerUp2_2_2(),
           axl.Cooperator()]

# Setting tournament with 200 turns and repetitions with 20
tournament = axl.Tournament(players, turns = 200, repetitions = 20)
# Run the tournament and save the result into results
results = tournament.play()
# Output the rank of choosen strategies
results.ranked_names

# Save results into csv file
results.write_summary('Milestone_3_result.csv')

# Save all results plots
plot = axl.Plot(results)
axl.Plot.save_all_plots(plot, 'Milestone_3', filetype = 'png')