Skip to content

Commit 0e80145

Browse files
committed
Add a test that implemented strategies agree.
I am only testing the deterministic strategies but have found 3 strategies that do not agree. They are currently ignored in `known_failures`. Opening an issue.
1 parent d97d640 commit 0e80145

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests/test_player.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from axelrod_fortran.strategies import characteristics, all_strategies
22
from axelrod_fortran import Player
33
from axelrod import (Alternator, Cooperator, Defector,
4-
Match, Game, basic_strategies)
4+
Match, Game, basic_strategies, seed)
55
from axelrod.action import Action
66
from ctypes import c_int, c_float, POINTER
77

@@ -111,3 +111,24 @@ def test_deterministic_strategies():
111111
interactions = match.play()
112112
for _ in range(2): # Repeat 3 matches
113113
assert interactions == match.play(), player
114+
115+
116+
def test_implemented_strategies():
117+
"""
118+
Test that the deterministic strategies that are implemented in Axelrod
119+
give the same outcomes.
120+
"""
121+
known_failures = ["k57r", "k59r", "k86r"]
122+
for strategy, dictionary in characteristics.items():
123+
axelrod_class = dictionary["axelrod-python_class"]
124+
player = Player(strategy)
125+
if (axelrod_class is not None and
126+
strategy not in known_failures and
127+
player.classifier["stochastic"] is False):
128+
axl_player = axelrod_class()
129+
for opponent_strategy in basic_strategies:
130+
opponent = opponent_strategy()
131+
match = Match((player, opponent))
132+
interactions = match.play()
133+
axl_match = Match((axl_player, opponent))
134+
assert interactions == axl_match.play(), (player, opponent)

0 commit comments

Comments
 (0)