Skip to content

ZeroDivisionError in FirstByDowning #1285

Description

@marcharper

There's an implicit assumption that self.defections != 0 when turn > 3 in the calculation of beta but if the Match is noisy this can be violated:

>>> import axelrod as axl
>>> player1 = axl.FirstByDowning()
>>> player2 = axl.Defector()
>>> match = axl.Match((player1, player2), turns=3, noise=0.99)
>>> match.play()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/repos/axelrod/Axelrod/axelrod/match.py", line 189, in play
    self.players[0], self.players[1], self.noise)
  File "/home/user/repos/axelrod/Axelrod/axelrod/match.py", line 141, in simultaneous_play
    s1, s2 = player.strategy(coplayer), coplayer.strategy(player)
  File "/home/user/repos/axelrod/Axelrod/axelrod/strategies/axelrod_first.py", line 268, in strategy
    beta = (self.number_opponent_cooperations_in_response_to_D /
ZeroDivisionError: division by zero

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions