Skip to content

Commit b31de75

Browse files
committed
Add code snippet to rerun Axelrod's second tournament to readme
1 parent 5965de5 commit b31de75

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

README.rst

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,36 @@ Installation
1818
Usage
1919
=====
2020

21-
::
21+
Running a match:
22+
23+
.. code-block:: python
24+
25+
>>> import axelrod_fortran as axlf
26+
>>> import axelrod as axl
27+
>>> p1 = axlf.Player('k31r')
28+
>>> p2 = axlf.Player('k33r')
29+
>>> match = axl.Match((p1, p2), turns=5)
30+
>>> match.play()
31+
[(C, C), (C, C), (C, D), (C, D), (C, C)]
32+
33+
Reproducing Axelrod's second tournament:
34+
35+
.. code-block:: python
36+
37+
import axelrod as axl
38+
from axelrod_fortran.strategies import characteristics
39+
from axelrod_fortran.player import Player
40+
41+
players = [Player(name) for name in characteristics.keys()
42+
if characteristics[name]["original_rank"] is not None]
43+
44+
print(len(players), "players")
2245
23-
>>> import axelrod_fortran as axlf
24-
>>> import axelrod as axl
25-
>>> p1 = axlf.Player('k31r')
26-
>>> p2 = axlf.Player('k33r')
27-
>>> match = axl.Match((p1, p2), turns=5)
28-
>>> match.play()
29-
[(C, C), (C, C), (C, D), (C, D), (C, C)]
46+
tournament = axl.Tournament(players, repetitions=100)
47+
results = tournament.play(processes=4)
48+
results.write_summary('summary.csv')
49+
plot = axl.Plot(results)
50+
plot.save_all_plots("second_tournament")
3051
3152
Contributing
3253
============

src/axelrod_fortran/player.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import axelrod as axl
44
from axelrod.interaction_utils import compute_final_score
55
from axelrod.action import Action
6-
from axelrod import Game
76
from ctypes import cdll, c_int, c_float, byref, POINTER
87
from .strategies import characteristics
98

@@ -49,7 +48,7 @@ def original_name(self, value):
4948
if value in characteristics:
5049
self.__original_name = value
5150
else:
52-
raise ValueError(f'{value} is not a valid Fortran function')
51+
raise ValueError('{} is not a valid Fortran function'.format(value))
5352

5453
@property
5554
def original_function(self):

0 commit comments

Comments
 (0)