Skip to content

Commit d97d640

Browse files
committed
Change characteristics to have class as value.
Also add a condition so that we only sample a random value if we know we might need one. Closes #25
1 parent 07c4446 commit d97d640

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/axelrod_fortran/player.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ def strategy(self, opponent):
8383
game=self.match_attributes["game"])
8484
my_last_move = original_actions[self.history[-1]]
8585
move_number = len(self.history) + 1
86-
random_value = random.random()
86+
if self.classifier["stochastic"]:
87+
random_value = random.random()
88+
else:
89+
random_value = 0
8790
original_action = self.original_strategy(
8891
their_last_move, move_number, scores[0], scores[1], random_value,
8992
my_last_move)

src/axelrod_fortran/strategies.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import axelrod as axl
2+
13
characteristics = {
24
'grasr': {
35
'axelrod-python_class': None,
@@ -20,7 +22,7 @@
2022
'author': None,
2123
'original_rank': None},
2224
'k34r': {
23-
'axelrod-python_class': 'Grudger',
25+
'axelrod-python_class': axl.Grudger,
2426
'stochastic': False,
2527
'author': None,
2628
'original_rank': None},
@@ -80,7 +82,7 @@
8082
'author': None,
8183
'original_rank': None},
8284
'k46r': {
83-
'axelrod-python_class': 'Eatherley',
85+
'axelrod-python_class': axl.Eatherley,
8486
'stochastic': True,
8587
'author': None,
8688
'original_rank': None},
@@ -135,7 +137,7 @@
135137
'author': None,
136138
'original_rank': None},
137139
'k57r': {
138-
'axelrod-python_class': 'Nydegger',
140+
'axelrod-python_class': axl.Nydegger,
139141
'stochastic': False,
140142
'author': None,
141143
'original_rank': None},
@@ -145,7 +147,7 @@
145147
'author': None,
146148
'original_rank': None},
147149
'k59r': {
148-
'axelrod-python_class': 'RevisedDowning',
150+
'axelrod-python_class': axl.RevisedDowning,
149151
'stochastic': False,
150152
'author': None,
151153
'original_rank': None},
@@ -155,7 +157,7 @@
155157
'author': None,
156158
'original_rank': None},
157159
'k61r': {
158-
'axelrod-python_class': 'Champion',
160+
'axelrod-python_class': axl.Champion,
159161
'stochastic': True,
160162
'author': None,
161163
'original_rank': None},
@@ -195,7 +197,7 @@
195197
'author': None,
196198
'original_rank': None},
197199
'k69r': {
198-
'axelrod-python_class': 'Joss',
200+
'axelrod-python_class': axl.Joss,
199201
'stochastic': True,
200202
'author': None,
201203
'original_rank': None},
@@ -235,12 +237,12 @@
235237
'author': None,
236238
'original_rank': None},
237239
'k76r': {
238-
'axelrod-python_class': 'Tester',
240+
'axelrod-python_class': axl.Tester,
239241
'stochastic': False,
240242
'author': None,
241243
'original_rank': None},
242244
'k77r': {
243-
'axelrod-python_class': 'Feld',
245+
'axelrod-python_class': axl.Feld,
244246
'stochastic': True,
245247
'author': None,
246248
'original_rank': None},
@@ -285,7 +287,7 @@
285287
'author': None,
286288
'original_rank': None},
287289
'k86r': {
288-
'axelrod-python_class': 'Grofman',
290+
'axelrod-python_class': axl.Grofman,
289291
'stochastic': False,
290292
'author': None,
291293
'original_rank': None},
@@ -320,27 +322,27 @@
320322
'author': None,
321323
'original_rank': None},
322324
'k93r': {
323-
'axelrod-python_class': 'UnnamedStrategy',
325+
'axelrod-python_class': axl.UnnamedStrategy,
324326
'stochastic': True,
325327
'author': None,
326328
'original_rank': None},
327329
'kpavlovc': {
328-
'axelrod-python_class': 'WinStayLoseShift',
330+
'axelrod-python_class': axl.WinStayLoseShift,
329331
'stochastic': False,
330332
'author': None,
331333
'original_rank': None},
332334
'krandomc': {
333-
'axelrod-python_class': 'Random',
335+
'axelrod-python_class': axl.Random,
334336
'stochastic': True,
335337
'author': None,
336338
'original_rank': None},
337339
'ktf2tc': {
338-
'axelrod-python_class': 'TitFor2Tats',
340+
'axelrod-python_class': axl.TitFor2Tats,
339341
'stochastic': False,
340342
'author': None,
341343
'original_rank': None},
342344
'ktitfortatc': {
343-
'axelrod-python_class': 'TitForTat',
345+
'axelrod-python_class': axl.TitForTat,
344346
'stochastic': False,
345347
'author': None,
346348
'original_rank': None},

0 commit comments

Comments
 (0)