コード例 #1
0
ファイル: test_appeaser.py プロジェクト: tscizzle/Axelrod
    def test_effect_of_strategy(self):
        P1 = axelrod.Appeaser()
        P2 = axelrod.Cooperator()
        self.assertEqual(P1.strategy(P2), C)

        self.responses_test([C], [C], [C, C, C])
        self.responses_test([C, D, C, D], [C, C, D], [D])
        self.responses_test([C, D, C, D, C], [C, C, D, D], [C])
        self.responses_test([C, D, C, D, C, D], [C, C, D, D, D], [D])
コード例 #2
0
ファイル: test_appeaser.py プロジェクト: mmmuhan/Axelrod
 def test_strategy(self):
     P1 = axelrod.Appeaser()
     P2 = axelrod.Player()
     P1.str = 'C'
     self.assertEqual(P1.strategy(P2), 'C')
     P1.history = ['C']
     P2.history = ['C']
     self.assertEqual(P1.strategy(P2), 'C')
     P1.history = ['C', 'D', 'C']
     P2.history = ['C', 'C', 'D']
     self.assertEqual(P1.strategy(P2), 'D')
コード例 #3
0
            j = random.random()
            #Let Mr Hyde and Dr Jykle compete
            #If Dr Jykle beats Mr Hyde cooperate else defect
            if h - j >= 0:
                return C
            else:
                return D


hj = DrJekyllMrHyde()  #Create instance of class

#players = [s() for s in axl.short_run_time_strategies]  # Create players
players = [
    hj,
    axl.Defector(),
    axl.TitForTat(),
    axl.Thumper(),
    axl.Punisher(),
    axl.AdaptiveTitForTat(),
    axl.FirstByDavis(),
    axl.Appeaser()
]
#players.append(hj)
tournament = Tournament(players)  # Create a tournament
results = tournament.play()  # Play the tournament

results.write_summary('SummaryMileStone3.csv')  # Write results to csv file

plot = axl.Plot(results)
p = plot.boxplot()  #Plot results
p.show()
コード例 #4
0
 def test_stochastic(self):
     self.assertFalse(axelrod.Appeaser().stochastic)
コード例 #5
0
 def test_representation(self):
     P1 = axelrod.Appeaser()
     self.assertEqual(str(P1), 'Appeaser')