Skip to content

Modify/fix initial play of lookerup players. #1190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2018
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
5 changes: 3 additions & 2 deletions axelrod/strategies/lookerup.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,9 @@ def _get_initial_actions(self, initial_actions: tuple) -> tuple:
return initial_actions[:table_depth]

def strategy(self, opponent: Player) -> Reaction:
while self._initial_actions_pool:
return self._initial_actions_pool.pop(0)
turn_index = len(opponent.history)
while turn_index < len(self._initial_actions_pool):
return self._initial_actions_pool[turn_index]

player_last_n_plays = get_last_n_plays(player=self,
depth=self._lookup.player_depth)
Expand Down
11 changes: 11 additions & 0 deletions axelrod/tests/strategies/test_geller.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ def test_strategy(self):
self.versus_test(axelrod.Cooperator(), expected_actions=[(C, C)] * 5)
self.versus_test(axelrod.Alternator(), expected_actions=[(C, C), (D, D)] * 5)


def test_strategy_against_lookerup_players(self):
"""
Regression test for a bug discussed in
https://github.com/Axelrod-Python/Axelrod/issues/1185
"""
self.versus_test(axelrod.EvolvedLookerUp1_1_1(),
expected_actions=[(C, C), (C, C)])
self.versus_test(axelrod.EvolvedLookerUp2_2_2(),
expected_actions=[(C, C), (C, C)])

def test_returns_foil_inspection_strategy_of_opponent(self):
seed = 2
# each Geller type returns the other's foil_inspection_strategy
Expand Down