Skip to content

Commit 651cfe0

Browse files
authored
Merge pull request #26 from Axelrod-Python/tests-for-deterministic-strategies
Write a test for deterministic strategies.
2 parents 40c5f13 + eef919e commit 651cfe0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/test_player.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from axelrod_fortran.strategies import characteristics, all_strategies
22
from axelrod_fortran import Player
3-
from axelrod import Alternator, Cooperator, Defector, Match, Game
3+
from axelrod import (Alternator, Cooperator, Defector,
4+
Match, Game, basic_strategies)
45
from axelrod.action import Action
56
from ctypes import c_int, c_float, POINTER
67

@@ -93,3 +94,17 @@ def test_original_strategy():
9394
their_previous_action = action
9495
my_score += scores[0]
9596
their_score += scores[1]
97+
98+
def test_deterministic_strategies():
99+
"""
100+
Test that the strategies classified as deterministic indeed act
101+
deterministically.
102+
"""
103+
for strategy in all_strategies:
104+
player = Player(strategy)
105+
if player.classifier["stochastic"] is False:
106+
for opponent in basic_strategies:
107+
match = Match((player, opponent()))
108+
interactions = match.play()
109+
for _ in range(2): # Repeat 3 matches
110+
assert interactions == match.play(), player

0 commit comments

Comments
 (0)