Skip to content

Commit 2639d8a

Browse files
committed
Merge pull request #288 from Axelrod-Python/287
Adding docs for non default arguments
2 parents 7a968cd + 09f2ba3 commit 2639d8a

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

docs/usage.rst

Lines changed: 42 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,14 @@ 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+
There are a variety of graphical outputs that the library can produce.
159162

160163
Let us see the global scores for the basic strategies::
161164

@@ -179,6 +182,42 @@ If we run the same tournament but with 5 :code:`Defector` and 3 :code:`TitForTat
179182
:width: 50%
180183
:align: center
181184

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

183222
Payoff matrix
184223
^^^^^^^^^^^^^

0 commit comments

Comments
 (0)