Skip to content

Commit df0ae01

Browse files
committed
Hide trailing underscore in fortran function name
1 parent 2566471 commit df0ae01

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/axelrod_fortran/player.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, original_name):
2121
"""
2222
super().__init__()
2323
self.original_name = original_name
24-
self.original_function = strategies[self.original_name]
24+
self.original_function = self.original_name
2525

2626
@property
2727
def original_name(self):
@@ -38,11 +38,11 @@ def original_function(self):
3838

3939
@original_function.setter
4040
def original_function(self, value):
41-
self.__original_function = value
42-
self.original_function.argtypes = (
41+
self.__original_function = strategies[(value + '_').lower()]
42+
self.__original_function.argtypes = (
4343
POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int),
4444
POINTER(c_float))
45-
self.original_function.restype = c_int
45+
self.__original_function.restype = c_int
4646

4747
def original_strategy(
4848
self, their_last_move, move_number, my_score, their_score, noise,
@@ -70,4 +70,4 @@ def strategy(self, opponent, noise=0):
7070

7171
def reset(self):
7272
super().reset()
73-
self.original_function = strategies[self.original_name]
73+
self.original_function = self.original_name

tests/test_titfortat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66

77

88
def test_versus_alternator():
9-
players = (Player('ktitfortatc_'), axl.Alternator())
9+
players = (Player('ktitfortatc'), axl.Alternator())
1010
match = axl.Match(players, 5)
1111
expected = [(C, C), (C, D), (D, C), (C, D), (D, C)]
1212
assert match.play() == expected
1313

1414

1515
def test_versus_cooperator():
16-
players = (Player('ktitfortatc_'), axl.Cooperator())
16+
players = (Player('ktitfortatc'), axl.Cooperator())
1717
match = axl.Match(players, 5)
1818
expected = [(C, C), (C, C), (C, C), (C, C), (C, C)]
1919
assert match.play() == expected
2020

2121

2222
def test_versus_defector():
23-
players = (Player('ktitfortatc_'), axl.Defector())
23+
players = (Player('ktitfortatc'), axl.Defector())
2424
match = axl.Match(players, 5)
2525
expected = [(C, D), (D, D), (D, D), (D, D), (D, D)]
2626
assert match.play() == expected

0 commit comments

Comments
 (0)