@@ -1815,3 +1815,96 @@ def test_strategy(self):
18151815 Change_of_Heart , expected_actions = actions , attrs = {"credit" : - 2 }
18161816 )
18171817 # Still Cooperate, because Defect rate is low
1818+
1819+ class TestRowsam (TestPlayer ):
1820+ name = "Rowsam"
1821+ player = axelrod .Rowsam
1822+ expected_classifier = {
1823+ "memory_depth" : float ("inf" ),
1824+ "stochastic" : False ,
1825+ "makes_use_of" : set ("game" ),
1826+ "long_run_time" : False ,
1827+ "inspects_source" : False ,
1828+ "manipulates_source" : False ,
1829+ "manipulates_state" : False ,
1830+ }
1831+
1832+ def test_strategy (self ):
1833+ # Should always cooperate with Cooperator
1834+ actions = [(C , C )] * 100
1835+ self .versus_test (axelrod .Cooperator (), expected_actions = actions )
1836+
1837+ # Against a Defector should eventually enter Defect mode
1838+ actions = [(C , D )] * 5
1839+ actions += [(D , D ), (C , D ), (D , D )] # Do a Coop-Def cycle
1840+ self .versus_test (axelrod .Defector (), expected_actions = actions , attrs = {
1841+ "distrust_points" : 5 })
1842+ actions += [(C , D )] * 3 # Continue for now
1843+ actions += [(D , D )] * 100 # Now Defect mode
1844+ self .versus_test (axelrod .Defector (), expected_actions = actions , attrs = {
1845+ "distrust_points" : 10 , "mode" : "Defect" })
1846+
1847+ # Test specific score scenarios
1848+ # 5 Defects
1849+ opponent_actions = [D ] * 5 + [C ] * 100
1850+ custom_opponent = axelrod .MockPlayer (actions = opponent_actions )
1851+ actions = [(C , D )] * 5
1852+ actions += [(D , C )]
1853+ self .versus_test (custom_opponent , expected_actions = actions , attrs = {
1854+ "distrust_points" : 5 , "current_score" : 0 })
1855+
1856+ # 3 Defects
1857+ opponent_actions = [D ] * 3 + [C ] * 100
1858+ custom_opponent = axelrod .MockPlayer (actions = opponent_actions )
1859+ actions = [(C , D )] * 3
1860+ actions += [(C , C )] * 2
1861+ actions += [(D , C )]
1862+ self .versus_test (custom_opponent , expected_actions = actions , attrs = {
1863+ "distrust_points" : 3 , "current_score" : 6 })
1864+
1865+ # 2 Defects
1866+ opponent_actions = [D ] * 2 + [C ] * 100
1867+ custom_opponent = axelrod .MockPlayer (actions = opponent_actions )
1868+ actions = [(C , D )] * 2
1869+ actions += [(C , C )] * 3
1870+ actions += [(D , C )]
1871+ self .versus_test (custom_opponent , expected_actions = actions , attrs = {
1872+ "distrust_points" : 2 , "current_score" : 9 })
1873+
1874+ # 1 Defect
1875+ opponent_actions = [D ] * 1 + [C ] * 100
1876+ custom_opponent = axelrod .MockPlayer (actions = opponent_actions )
1877+ actions = [(C , D )] * 1
1878+ actions += [(C , C )] * 4
1879+ actions += [(D , C )]
1880+ self .versus_test (custom_opponent , expected_actions = actions , attrs = {
1881+ "distrust_points" : 1 , "current_score" : 12 })
1882+
1883+ # Test that some distrust_points wear off.
1884+ opponent_actions = [D ] * 3 + [C ] * 100
1885+ custom_opponent = axelrod .MockPlayer (actions = opponent_actions )
1886+ actions = [(C , D )] * 3
1887+ actions += [(C , C )] * 2
1888+ actions += [(D , C )]
1889+ self .versus_test (custom_opponent , expected_actions = actions , attrs = {
1890+ "distrust_points" : 3 , "current_score" : 6 })
1891+ custom_opponent = axelrod .MockPlayer (actions = opponent_actions )
1892+ actions += [(C , C ), (D , C )] # Complete Coop-Def cycle
1893+ actions += [(C , C )] * 3
1894+ actions += [(D , C )]
1895+ self .versus_test (custom_opponent , expected_actions = actions , attrs = {
1896+ "distrust_points" : 4 , "current_score" : 28 })
1897+ custom_opponent = axelrod .MockPlayer (actions = opponent_actions )
1898+ actions += [(C , C ), (D , C )] # Complete Coop-Def cycle
1899+ actions += [(C , C )] * 4 # No defect or cycle this time.
1900+ self .versus_test (custom_opponent , expected_actions = actions , attrs = {
1901+ "distrust_points" : 3 , "current_score" : 50 }) # One point wears off.
1902+ custom_opponent = axelrod .MockPlayer (actions = opponent_actions )
1903+ actions += [(C , C )] * 18
1904+ self .versus_test (custom_opponent , expected_actions = actions , attrs = {
1905+ "distrust_points" : 2 }) # Second point wears off
1906+ custom_opponent = axelrod .MockPlayer (actions = opponent_actions )
1907+ actions += [(C , C )] * 18
1908+ self .versus_test (custom_opponent , expected_actions = actions , attrs = {
1909+ "distrust_points" : 2 }) # But no more
1910+
0 commit comments