Skip to content

Commit b7a51ad

Browse files
committed
Adding docs for non default arguments
- Adding an example and plot for different turns and repetitions - Adding a different game example - For both of those am also including a new plot
1 parent 1cee08e commit b7a51ad

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

docs/usage.rst

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Usage
22
=====
33

4-
This library is intended to allow for users to create their own tournaments (and incorporating various strategies as required) and comes with a script that runs the tournament with a variety of options:
4+
This library is intended to allow for users to create their own tournaments (and
5+
incorporating various strategies as required) and comes with a script that runs
6+
the tournament with a variety of options:
57

68
1. `Using as a library`_
79
2. `Running the tournament`_
@@ -149,13 +151,17 @@ gives::
149151

150152
3
151153

152-
So even with a large quantity of :code:`Defector` only a small number of :code:`TitForTat` strategies is required.
154+
So even with a large quantity of :code:`Defector` only a small number of
155+
:code:`TitForTat` strategies is required.
153156

154157

155158
Graphics
156159
^^^^^^^^
157160

158-
The whole library can be used without any other non base Python libraries however if you have `matplotlib <http://matplotlib.org/>`_ installed on your system (this is installed automatically if you used :code:`pip install axelrod`) there are various graphical things coded in and ready to go.
161+
The whole library can be used without any other non base Python libraries
162+
however if you have `matplotlib <http://matplotlib.org/>`_ installed on your
163+
system (this is installed automatically if you used :code:`pip install axelrod`)
164+
there are various graphical things coded in and ready to go.
159165

160166
Let us see the global scores for the basic strategies::
161167

@@ -179,6 +185,42 @@ If we run the same tournament but with 5 :code:`Defector` and 3 :code:`TitForTat
179185
:width: 50%
180186
:align: center
181187

188+
Non default arguments
189+
^^^^^^^^^^^^^^^^^^^^^
190+
191+
By default the tournament is run for 200 rounds and repeated 10 times. This are
192+
the default values and can be changed::
193+
194+
import axelrod
195+
strategies = [s() for s in axelrod.basic_strategies]
196+
tournament = axelrod.Tournament(strategies, turns=20, repetitions=50)
197+
results = tournament.play()
198+
plot = axelrod.Plot(results)
199+
p = plot.boxplot()
200+
p.show()
201+
202+
203+
.. image:: _static/usage/basic_strategies_20_turns_50_repetitions.svg
204+
:width: 50%
205+
:align: center
206+
207+
208+
There are various other arguments that can be passed including the actual game
209+
that is repeated. Here is an example showing the standard strategies playing a
210+
scaled version of the standard game::
211+
212+
import axelrod
213+
strategies = [s() for s in axelrod.basic_strategies]
214+
tournament = axelrod.Tournament(strategies, game=Game(30, 0, 50, 10))
215+
results = tournament.play()
216+
plot = axelrod.Plot(results)
217+
p = plot.boxplot()
218+
p.show()
219+
220+
221+
.. image:: _static/usage/basic_strategies_scaled_games.svg
222+
:width: 50%
223+
:align: center
182224

183225
Payoff matrix
184226
^^^^^^^^^^^^^

0 commit comments

Comments
 (0)