Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions axelrod/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,12 @@ def __eq__(self, other):
setattr(other, attribute,
itertools.cycle(original_other_value))

if not (all(next(generator) == next(other_generator)
for _ in range(200))):
return False
for _ in range(200):
try:
if next(generator) != next(other_generator):
return False
except StopIteration:
break

# Code for a strange edge case where each strategy points at each
# other
Expand Down
15 changes: 4 additions & 11 deletions axelrod/tests/strategies/test_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ def cooperate(*args):
def defect(*args):
return D


def randomize(*args):
return random.choice([C, D])

# Test classifier used to create tests players
_test_classifier = {
'memory_depth': 0,
Expand Down Expand Up @@ -98,13 +94,10 @@ def test_play(self):
self.assertEqual(player2.state_distribution, {(D, C): 2})

def test_state_distribution(self):
player1, player2 = self.player(), self.player()
player1.strategy = randomize
player2.strategy = randomize
history_1 = [C, C, D, D, C]
history_2 = [C, D, C, D, D]
for h1, h2 in zip(history_1, history_2):
simulate_play(player1, player2, h1, h2)
player1 = axelrod.MockPlayer([C, C, D, D, C])
player2 = axelrod.MockPlayer([C, D, C, D, D])
match = axelrod.Match((player1, player2), turns=5)
_ = match.play()
self.assertEqual(player1.state_distribution,
{(C, C): 1, (C, D): 2, (D, C): 1, (D, D): 1})
self.assertEqual(player2.state_distribution,
Expand Down