Skip to content

Commit 9c397ab

Browse files
drvinceknightAdamPohl
authored andcommitted
Correct strategy.
1 parent 384d49c commit 9c397ab

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

axelrod/strategies/worse_and_worse.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from axelrod import Actions, Player
2-
from random import randint, choice
1+
from axelrod import Actions, Player, random_choice
32

43
C, D = Actions.C, Actions.D
54

@@ -27,9 +26,5 @@ class WorseAndWorse (Player):
2726
def strategy(self, opponent):
2827
current_round = len(self.history) + 1
2928
expected_length = self.match_attributes['length']
30-
try:
31-
if randint(0, expected_length) < (current_round):
32-
return D
33-
return C
34-
except ValueError:
35-
choice([C, D])
29+
probability = 1 - float(current_round) / expected_length
30+
return random_choice(probability)

0 commit comments

Comments
 (0)