Skip to content

Commit be6a99f

Browse files
authored
Merge pull request #27 from Axelrod-Python/better-game-assignment
Change how the game is read in by the player.
2 parents 651cfe0 + 39fceea commit be6a99f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/axelrod_fortran/player.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Player(axl.Player):
1717

1818
classifier = {"stochastic": True}
1919

20-
def __init__(self, original_name, game=Game()):
20+
def __init__(self, original_name):
2121
"""
2222
Parameters
2323
----------
@@ -30,7 +30,6 @@ def __init__(self, original_name, game=Game()):
3030
super().__init__()
3131
self.original_name = original_name
3232
self.original_function = self.original_name
33-
self.game = game
3433
is_stochastic = characteristics[self.original_name]['stochastic']
3534
if is_stochastic is not None:
3635
self.classifier['stochastic'] = is_stochastic
@@ -79,7 +78,7 @@ def strategy(self, opponent):
7978
else:
8079
their_last_move = original_actions[opponent.history[-1]]
8180
scores = compute_final_score(zip(self.history, opponent.history),
82-
game=self.game)
81+
game=self.match_attributes["game"])
8382
my_last_move = original_actions[self.history[-1]]
8483
move_number = len(self.history) + 1
8584
random_value = random.random()

tests/test_player.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_matches_with_different_game():
5656
for strategy in all_strategies:
5757
for opponent in (Alternator, Cooperator, Defector):
5858
game = Game(r=4, s=0, p=2, t=6)
59-
players = (Player(strategy, game=game), opponent())
59+
players = (Player(strategy), opponent())
6060
match = Match(players, turns=200, game=game)
6161
assert all(
6262
action in (C, D) for interaction in match.play()

0 commit comments

Comments
 (0)