|
1 | 1 | """Tests for the Second Axelrod strategies."""
|
2 | 2 |
|
3 | 3 | import random
|
| 4 | +import numpy as np |
4 | 5 |
|
5 | 6 | import axelrod
|
6 | 7 | from .test_player import TestPlayer
|
@@ -819,3 +820,32 @@ def test_strategy(self):
|
819 | 820 | # doesn't reset. This logic comes before parity streaks or the turn-
|
820 | 821 | # based logic.
|
821 | 822 | self.versus_test(axelrod.Defector(), expected_actions=actions, attrs={"recorded_defects": 119})
|
| 823 | + |
| 824 | + # Detect random |
| 825 | + actions = [(C, D), (D, C), (C, D), (D, C), (C, D), (C, D), (D, D), |
| 826 | + (D, C), (C, D), (D, C), (C, C), (C, D), (D, D), (D, C), |
| 827 | + (C, D), (D, D), (D, C), (C, C), (C, D), (D, C), (C, D), |
| 828 | + (D, D), (D, C), (C, D), (D, D), (D, D), (C, D), (D, C), |
| 829 | + (C, C)] |
| 830 | + # Enter defect mode. |
| 831 | + actions += [(D, C)] |
| 832 | + self.versus_test(axelrod.Random(0.5), expected_actions=actions, seed=10, attrs={"chi_squared": 2.395}) |
| 833 | + # The history matrix will be [[0, 2], [5, 6], [3, 6], [4, 2]] |
| 834 | + |
| 835 | + # Come back out of defect mode |
| 836 | + opponent_actions = [D, C, D, C, D, D, D, C, D, C, C, D, D, C, D, D, C, |
| 837 | + C, D, C, D, D, C, D, D, D, D, C, C, C] |
| 838 | + opponent_actions += [D] * 16 |
| 839 | + Rand_Then_Def = axelrod.MockPlayer(actions=opponent_actions) |
| 840 | + actions = [(C, D), (D, C), (C, D), (D, C), (C, D), (C, D), (D, D), |
| 841 | + (D, C), (C, D), (D, C), (C, C), (C, D), (D, D), (D, C), |
| 842 | + (C, D), (D, D), (D, C), (C, C), (C, D), (D, C), (C, D), |
| 843 | + (D, D), (D, C), (C, D), (D, D), (D, D), (C, D), (D, C), |
| 844 | + (C, C)] |
| 845 | + actions += [(D, C)] |
| 846 | + # Enter defect mode. |
| 847 | + actions += [(D, D)] * 14 |
| 848 | + # Mutual defect for a while, then exit Defect mode with two coops |
| 849 | + actions += [(C, D)] * 2 |
| 850 | + self.versus_test(Rand_Then_Def, expected_actions=actions, seed=10, \ |
| 851 | + attrs={"mode": "Normal", "was_defective": True}) |
0 commit comments