コード例 #1
0
    def test_vs_defect(self):
        """ Will force even defector to cooperate """

        P1 = axelrod.MindControl()
        P2 = axelrod.Defector()
        self.assertEqual(P1.strategy(P2), 'D')
        self.assertEqual(P2.strategy(P1), 'C')
コード例 #2
0
    def test_vs_cooperator(self):
        """ Will always make opponent cooperate """

        P1 = axelrod.MindControl()
        P2 = axelrod.Cooperator()
        self.assertEqual(P1.strategy(P2), 'D')
        self.assertEqual(P2.strategy(P1), 'C')
コード例 #3
0
    def test_vs_grudger(self):
        """ Will force even Grudger to forget its grudges"""

        P1 = axelrod.MindControl()
        P2 = axelrod.Grudger()
        P1.history = [
            'D',
            'D',
            'D',
            'D',
        ]
        self.assertEqual(P1.strategy(P2), 'D')
        self.assertEqual(P2.strategy(P1), 'C')
コード例 #4
0
    def test_representation(self):
        """Tests that the string is correctly displayed"""

        P1 = axelrod.MindControl()
        self.assertEqual(str(P1), 'Mind Control')
コード例 #5
0
 def test_reset(self):
     """ test for the reset method """
     P1 = axelrod.MindControl()
     P1.history = ['C', 'D', 'D', 'D']
     P1.reset()
     self.assertEqual(P1.history, [])
コード例 #6
0
    def test_init(self):
        """Test to make sure parameters are initialised correctly """

        P1 = axelrod.MindControl()
        self.assertEqual(P1.history, [])
        self.assertEqual(P1.score, 0)
コード例 #7
0
 def test_stochastic(self):
     """Test to see if the method is stochastic or not (Important for caching results)"""
     self.assertFalse(axelrod.MindControl().stochastic)