|
9 | 9 | from axelrod.action import Action |
10 | 10 | from axelrod.player import Player |
11 | 11 | from axelrod.random_ import random_choice |
| 12 | +from axelrod.strategies.finite_state_machines import FSMPlayer |
12 | 13 |
|
13 | 14 | from axelrod.interaction_utils import compute_final_score |
14 | 15 |
|
@@ -1803,3 +1804,50 @@ def strategy(self, opponent: Player) -> Action: |
1803 | 1804 | self.count_them_us_them[(them_two_ago, us_last, D)]: |
1804 | 1805 | return self.try_return(C, opponent.defections) |
1805 | 1806 | return self.try_return(D, opponent.defections) |
| 1807 | + |
| 1808 | + |
| 1809 | +class Colbert(FSMPlayer): |
| 1810 | + """ |
| 1811 | + Strategy submitted to Axelrod's second tournament by William Colbert (K51R) |
| 1812 | + and came in eighteenth in that tournament. |
| 1813 | +
|
| 1814 | + In the first eight turns, this strategy Coopearates on all but the sixth |
| 1815 | + turn, in which it Defects. After that, the strategy responds to an |
| 1816 | + opponent Cooperation with a single Cooperation, and responds to a Defection |
| 1817 | + with a chain of responses: Defect, Defect, Cooperate, Cooperate. During |
| 1818 | + this chain, the strategy ignores opponent's moves. |
| 1819 | +
|
| 1820 | + Names: |
| 1821 | +
|
| 1822 | + - Colbert: [Axelrod1980b]_ |
| 1823 | + """ |
| 1824 | + |
| 1825 | + name = "Colbert" |
| 1826 | + classifier = { |
| 1827 | + 'memory_depth': 4, |
| 1828 | + 'stochastic': False, |
| 1829 | + 'makes_use_of': set(), |
| 1830 | + 'long_run_time': False, |
| 1831 | + 'inspects_source': False, |
| 1832 | + 'manipulates_source': False, |
| 1833 | + 'manipulates_state': False |
| 1834 | + } |
| 1835 | + |
| 1836 | + def __init__(self) -> None: |
| 1837 | + transitions = ( |
| 1838 | + (0, C, 1, C), (0, D, 1, C), # First 8 turns are special |
| 1839 | + (1, C, 2, C), (1, D, 2, C), |
| 1840 | + (2, C, 3, C), (2, D, 3, C), |
| 1841 | + (3, C, 4, C), (3, D, 4, C), |
| 1842 | + (4, C, 5, D), (4, D, 5, D), # Defect on 6th turn. |
| 1843 | + (5, C, 6, C), (5, D, 6, C), |
| 1844 | + (6, C, 7, C), (6, D, 7, C), |
| 1845 | + |
| 1846 | + (7, C, 7, C), (7, D, 8, D), |
| 1847 | + (8, C, 9, D), (8, D, 9, D), |
| 1848 | + (9, C, 10, C), (9, D, 10, C), |
| 1849 | + (10, C, 7, C), (10, D, 7, C) |
| 1850 | + ) |
| 1851 | + |
| 1852 | + super().__init__(transitions=transitions, initial_state=0, |
| 1853 | + initial_action=C) |
0 commit comments