Skip to content

Commit d9eceb4

Browse files
drvinceknightmarcharper
authored andcommitted
Fragment the result set documentation.
Closes #985. Also tweaked some minor stylistic issues.
1 parent 76d1593 commit d9eceb4

File tree

6 files changed

+49
-32
lines changed

6 files changed

+49
-32
lines changed

docs/tutorials/advanced/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Contents:
1212
classification_of_strategies.rst
1313
strategy_transformers.rst
1414
making_tournaments.rst
15+
tournament_results.rst
1516
reading_and_writing_interactions.rst
1617
parallel_processing.rst
1718
using_the_cache.rst

docs/tutorials/getting_started/tournament_results.rst renamed to docs/tutorials/advanced/tournament_results.rst

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -370,31 +370,3 @@ of the cooperation rating::
370370
[0.57..., 0.0, 0.57..., 0.57...]
371371

372372
For more information about these see :ref:`morality-metrics`.
373-
374-
Summarising a tournament
375-
------------------------
376-
377-
The results set can also return a list of named tuples, ordered by strategy rank
378-
that summarises the results of the tournament::
379-
380-
>>> summary = results.summarise()
381-
>>> pprint.pprint(summary)
382-
[Player(Rank=0, Name='Defector', Median_score=2.6..., Cooperation_rating=0.0, Wins=3.0, Initial_C_rate=0.0, CC_rate=...),
383-
Player(Rank=1, Name='Tit For Tat', Median_score=2.3..., Cooperation_rating=0.7, Wins=0.0, Initial_C_rate=1.0, CC_rate=...),
384-
Player(Rank=2, Name='Grudger', Median_score=2.3..., Cooperation_rating=0.7, Wins=0.0, Initial_C_rate=1.0, CC_rate=...),
385-
Player(Rank=3, Name='Cooperator', Median_score=2.0..., Cooperation_rating=1.0, Wins=0.0, Initial_C_rate=1.0, CC_rate=...)]
386-
387-
It is also possible to write this data directly to a csv file using the
388-
`write_summary` method::
389-
390-
>>> results.write_summary('summary.csv')
391-
>>> import csv
392-
>>> with open('summary.csv', 'r') as outfile:
393-
... csvreader = csv.reader(outfile)
394-
... for row in csvreader:
395-
... print(row)
396-
['Rank', 'Name', 'Median_score', 'Cooperation_rating', 'Wins', 'Initial_C_rate', 'CC_rate', 'CD_rate', 'DC_rate', 'DD_rate', 'CC_to_C_rate', 'CD_to_C_rate', 'DC_to_C_rate', 'DD_to_C_rate']
397-
['0', 'Defector', '2.6...', '0.0', '3.0', '0.0', '0.0', '0.0', '0.4...', '0.6...', '0', '0', '0', '0']
398-
['1', 'Tit For Tat', '2.3...', '0.7', '0.0', '1.0', '0.66...', '0.03...', '0.0', '0.3...', '1.0', '0', '0', '0']
399-
['2', 'Grudger', '2.3...', '0.7', '0.0', '1.0', '0.66...', '0.03...', '0.0', '0.3...', '1.0', '0', '0', '0']
400-
['3', 'Cooperator', '2.0...', '1.0', '0.0', '1.0', '0.66...', '0.33...', '0.0', '0.0', '1.0', '1.0', '0', '0']

docs/tutorials/further_topics/approximate_moran_processes.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ Now let us create an Approximate Moran Process::
2626
>>> amp.population_distribution()
2727
Counter({'Random: 0.5': 3})
2828

29-
We see that the :code:`Random: 0.5` won this Moran process. This is not what happens in a
30-
standard Moran process where the `Random: 0.5` player will not win::
29+
We see that the :code:`Random: 0.5` won this Moran process. This is not what
30+
happens in a standard Moran process where the :code:`Random: 0.5` player will
31+
not win::
3132

3233
>>> axl.seed(2)
3334
>>> amp = axl.MoranProcess(players)

docs/tutorials/further_topics/morality_metrics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Morality Metrics
44
================
55

66
Tyler Singer-Clark's June 2014 paper, "Morality Metrics On Iterated Prisoner’s
7-
Dilemma Players" [Tyler-Clark2014]), describes several interesting metrics which
7+
Dilemma Players" [Singer-Clark2014]_), describes several interesting metrics which
88
may be used to analyse IPD tournaments all of which are available within the
99
ResultSet class. (Tyler's paper is available here:
1010
http://www.scottaaronson.com/morality.pdf).

docs/tutorials/getting_started/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Contents:
1212
installation.rst
1313
match.rst
1414
tournament.rst
15-
tournament_results.rst
15+
summarising_tournaments.rst
1616
interactions.rst
1717
visualising_results.rst
1818
moran.rst
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.. _tournament-results-summary:
2+
3+
Summarising tournament results
4+
==============================
5+
6+
7+
As shown in :ref:`creating_tournaments` let us create a tournament::
8+
9+
>>> import axelrod as axl
10+
>>> players = [axl.Cooperator(), axl.Defector(),
11+
... axl.TitForTat(), axl.Grudger()]
12+
>>> tournament = axl.Tournament(players, turns=10, repetitions=3)
13+
>>> results = tournament.play()
14+
15+
The results set can return a list of named tuples, ordered by strategy rank
16+
that summarises the results of the tournament::
17+
18+
>>> summary = results.summarise()
19+
>>> import pprint
20+
>>> pprint.pprint(summary)
21+
[Player(Rank=0, Name='Defector', Median_score=2.6..., Cooperation_rating=0.0, Wins=3.0, Initial_C_rate=0.0, CC_rate=...),
22+
Player(Rank=1, Name='Tit For Tat', Median_score=2.3..., Cooperation_rating=0.7, Wins=0.0, Initial_C_rate=1.0, CC_rate=...),
23+
Player(Rank=2, Name='Grudger', Median_score=2.3..., Cooperation_rating=0.7, Wins=0.0, Initial_C_rate=1.0, CC_rate=...),
24+
Player(Rank=3, Name='Cooperator', Median_score=2.0..., Cooperation_rating=1.0, Wins=0.0, Initial_C_rate=1.0, CC_rate=...)]
25+
26+
It is also possible to write this data directly to a csv file using the
27+
`write_summary` method::
28+
29+
>>> results.write_summary('summary.csv')
30+
>>> import csv
31+
>>> with open('summary.csv', 'r') as outfile:
32+
... csvreader = csv.reader(outfile)
33+
... for row in csvreader:
34+
... print(row)
35+
['Rank', 'Name', 'Median_score', 'Cooperation_rating', 'Wins', 'Initial_C_rate', 'CC_rate', 'CD_rate', 'DC_rate', 'DD_rate', 'CC_to_C_rate', 'CD_to_C_rate', 'DC_to_C_rate', 'DD_to_C_rate']
36+
['0', 'Defector', '2.6...', '0.0', '3.0', '0.0', '0.0', '0.0', '0.4...', '0.6...', '0', '0', '0', '0']
37+
['1', 'Tit For Tat', '2.3...', '0.7', '0.0', '1.0', '0.66...', '0.03...', '0.0', '0.3...', '1.0', '0', '0', '0']
38+
['2', 'Grudger', '2.3...', '0.7', '0.0', '1.0', '0.66...', '0.03...', '0.0', '0.3...', '1.0', '0', '0', '0']
39+
['3', 'Cooperator', '2.0...', '1.0', '0.0', '1.0', '0.66...', '0.33...', '0.0', '0.0', '1.0', '1.0', '0', '0']
40+
41+
42+
The result set class computes a large number of detailed outcomes read about
43+
those in :ref:`tournament-results`.

0 commit comments

Comments
 (0)