Skip to content

Commit 39c89f4

Browse files
committed
Fix stochastic behaviour of fortran functions
1 parent f7b115c commit 39c89f4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/axelrod_fortran/player.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import random
2+
13
import axelrod as axl
24
from axelrod.interaction_utils import compute_final_score
35
from axelrod.action import Action
@@ -57,15 +59,15 @@ def original_function(self, value):
5759
self.__original_function.restype = c_int
5860

5961
def original_strategy(
60-
self, their_last_move, move_number, my_score, their_score, noise,
62+
self, their_last_move, move_number, my_score, their_score, random_value,
6163
my_last_move
6264
):
6365
args = (
6466
c_int(their_last_move), c_int(move_number), c_int(my_score),
65-
c_int(their_score), c_float(noise), c_int(my_last_move))
67+
c_int(their_score), c_float(random_value), c_int(my_last_move))
6668
return self.original_function(*[byref(arg) for arg in args])
6769

68-
def strategy(self, opponent, noise=0):
70+
def strategy(self, opponent):
6971
if not self.history:
7072
their_last_move = 0
7173
scores = (0, 0)
@@ -76,8 +78,9 @@ def strategy(self, opponent, noise=0):
7678
game=self.game)
7779
my_last_move = original_actions[self.history[-1]]
7880
move_number = len(self.history) + 1
81+
random_value = random.random()
7982
original_action = self.original_strategy(
80-
their_last_move, move_number, scores[0], scores[1], noise,
83+
their_last_move, move_number, scores[0], scores[1], random_value,
8184
my_last_move)
8285
return actions[original_action]
8386

0 commit comments

Comments
 (0)