Skip to content

Commit

Permalink
branch switch
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-s-s authored and drvinceknight committed Aug 3, 2017
1 parent 05b1409 commit c8ae6cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
19 changes: 14 additions & 5 deletions axelrod/strategy_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,22 +299,31 @@ def dual_wrapper(player, opponent, proposed_action):
"""

if not player.history:
player.use_history = []
player.original_player_history = []

temp = player.history[:]
player.history = player.use_history[:]
temp_history = player.history[:]
player.history = player.original_player_history[:]

switch_cooperations_and_defections(player)

if is_strategy_static(player.original_class):
action = player.original_class.strategy(opponent)
else:
action = player.original_class.strategy(player, opponent)

player.history = temp[:]
player.history = temp_history[:]
switch_cooperations_and_defections(player)

player.use_history.append(action)
player.original_player_history.append(action)
return action.flip()


def switch_cooperations_and_defections(player):
temp = player.cooperations
player.cooperations = player.defections
player.defections = temp


DualTransformer = StrategyTransformerFactory(dual_wrapper, name_prefix="Dual")


Expand Down
5 changes: 2 additions & 3 deletions axelrod/tests/unit/test_pickling.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,9 @@ def test_regression_test_dual_jossann(self):
self.assert_dual_wrapper_correct(klass)

def test_dual_transformer_with_fsm_and_sequence_players(self):
self.assert_dual_wrapper_correct(axl.Fortress3)
self.assert_dual_wrapper_correct(axl.Fortress4)

self.assert_dual_wrapper_correct(axl.ThueMorse)
for s in axl.strategies:
self.assert_dual_wrapper_correct(s)

def assert_dual_wrapper_correct(self, player_class):
p1 = player_class()
Expand Down

0 comments on commit c8ae6cf

Please sign in to comment.