Skip to content

Commit 0bc6ed5

Browse files
authored
Merge pull request #687 from marcharper/docs
Docs and such
2 parents 92e2c64 + f007afe commit 0bc6ed5

File tree

13 files changed

+98
-49
lines changed

13 files changed

+98
-49
lines changed

README.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,24 @@
1515
Axelrod
1616
=======
1717

18-
A repository with the following goals:
18+
A library with the following principles and goals:
1919

20-
1. To enable the reproduction of previous Iterated Prisoner's Dilemma research as easily as possible.
21-
2. To produce the de-facto tool for any future Iterated Prisoner's Dilemma research.
22-
3. To provide as simple a means as possible for anyone to define and contribute
20+
1. Enabling the reproduction of previous Iterated Prisoner's Dilemma research
21+
as easily as possible.
22+
2. Creating the de-facto tool for future Iterated Prisoner's Dilemma
23+
research.
24+
3. Providing as simple a means as possible for anyone to define and contribute
2325
new and original Iterated Prisoner's Dilemma strategies.
26+
4. Emphasizing readability along with an open and welcoming community that
27+
is accommodating for developers and researchers of a variety of skill levels
2428

25-
**Please contribute strategies via pull request (or just get in touch
26-
with us).**
29+
Currently the library contains well over 100 strategies and can perform a
30+
variety of tournament types (RoundRobin, Noisy, Spatially-distributed, and
31+
probabilistically ending) and population dynamics while taking advantage
32+
of multi-core processors.
33+
34+
35+
**Please contribute via pull request (or just get in touch with us).**
2736

2837
For an overview of how to use and contribute to this repository, see the
2938
documentation: http://axelrod.readthedocs.org/
@@ -91,8 +100,7 @@ at http://axelrod-tournament.readthedocs.org.
91100
Contributing
92101
============
93102

94-
All contributions are welcome, with a particular emphasis on
95-
contributing further strategies.
103+
All contributions are welcome!
96104

97105
You can find helpful instructions about contributing in the
98106
documentation:

axelrod/_strategy_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def detect_cycle(history, min_size=1, offset=0):
1515
Mainly used by hunter strategies.
1616
1717
Parameters
18-
18+
----------
1919
history: sequence of C and D
2020
The sequence to look for cycles within
2121
min_size: int, 1
@@ -83,7 +83,7 @@ def look_ahead(player_1, player_2, game, rounds=10):
8383

8484

8585
class Memoized(object):
86-
"""Decorator. Caches a function's return value each time it is called.
86+
"""Decorator that caches a function's return value each time it is called.
8787
If called later with the same arguments, the cached value is returned
8888
(not reevaluated). From:
8989
https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize

axelrod/actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ def flip_action(action):
1010
elif action == Actions.D:
1111
return Actions.C
1212
else:
13-
raise ValueError("Encountered a invalid action")
13+
raise ValueError("Encountered a invalid action.")

axelrod/deterministic_cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,4 @@ def load(self, file_name):
144144
else:
145145
raise ValueError(
146146
'Cache file exists but is not the correct format. Try deleting and re-building the cache file.')
147-
148147
return True

axelrod/ecosystem.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ def __init__(self, results, fitness=None, population=None):
1111
self.payoff_matrix = self.results.payoff_matrix
1212
self.payoff_stddevs = self.results.payoff_stddevs
1313

14-
# Population sizes will be recorded in this nested list, with each internal
15-
# list containing strategy populations for a given turn. The first list,
16-
# representing the starting populations, will by default have all equal
17-
# values, and all population lists will be normalized to one.
18-
# An initial population vector can also be passed. This will be
19-
# normalised, but must be of the correct size and have all
20-
# non-negative values.
14+
# Population sizes will be recorded in this nested list, with each
15+
# internal list containing strategy populations for a given turn. The
16+
# first list, representing the starting populations, will by default
17+
# have all equal values, and all population lists will be normalized to
18+
# one. An initial population vector can also be passed. This will be
19+
# normalised, but must be of the correct size and have all non-negative
20+
# values.
2121
if population:
2222
if min(population) < 0:
2323
raise TypeError("Minimum value of population vector must be non-negative")
@@ -29,8 +29,8 @@ def __init__(self, results, fitness=None, population=None):
2929
else:
3030
self.population_sizes = [[1.0 / self.nplayers for i in range(self.nplayers)]]
3131

32-
# This function is quite arbitrary and probably only influences the kinetics
33-
# for the current code.
32+
# This function is quite arbitrary and probably only influences the
33+
# kinetics for the current code.
3434
if fitness:
3535
self.fitness = fitness
3636
else:
@@ -43,11 +43,12 @@ def reproduce(self, turns):
4343
plist = list(range(self.nplayers))
4444
pops = self.population_sizes[-1]
4545

46-
# The unit payoff for each player in this turn is the sum of the payoffs
47-
# obtained from playing with all other players, scaled by the size of the
48-
# opponent's population. Note that we sample the normal distribution
49-
# based on the payoff matrix and its standard deviations obtained from
50-
# the iterated PD tournament run previously.
46+
# The unit payoff for each player in this turn is the sum of the
47+
# payoffs obtained from playing with all other players, scaled by
48+
# the size of the opponent's population. Note that we sample the
49+
# normal distribution based on the payoff matrix and its standard
50+
# deviations obtained from the iterated PD tournament run
51+
# previously.
5152
payoffs = [0 for ip in plist]
5253
for ip in plist:
5354
for jp in plist:
@@ -56,9 +57,10 @@ def reproduce(self, turns):
5657
p = random.normalvariate(avg, dev)
5758
payoffs[ip] += p * pops[jp]
5859

59-
# The fitness should determine how well a strategy reproduces. The new populations
60-
# should be multiplied by something that is proportional to the fitness, but we are
61-
# normalizing anyway so just multiply times fitness.
60+
# The fitness should determine how well a strategy reproduces. The
61+
# new populations should be multiplied by something that is
62+
# proportional to the fitness, but we are normalizing anyway so
63+
# just multiply times fitness.
6264
fitness = [self.fitness(p) for p in payoffs]
6365
newpops = [p * f for p, f in zip(pops, fitness)]
6466

axelrod/game.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def __init__(self, r=3, s=0, t=5, p=1):
1515
}
1616

1717
def RPST(self):
18-
"""Return the values in the game matrix in the Press and Dyson notation."""
18+
"""Return the values in the game matrix in the Press and Dyson
19+
notation."""
1920
R = self.scores[(C, C)][0]
2021
P = self.scores[(D, D)][0]
2122
S = self.scores[(C, D)][0]

axelrod/match.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ def __init__(self, players, turns, game=None, deterministic_cache=None,
2626
The number of turns per match
2727
game : axelrod.Game
2828
The game object used to score the match
29-
deterministic_cache : dictionary
29+
deterministic_cache : axelrod.DeterministicCache
3030
A cache of resulting actions for deterministic matches
3131
noise : float
3232
The probability that a player's intended action should be flipped
3333
match_attributes : dict
3434
Mapping attribute names to values which should be passed to players.
3535
The default is to use the correct values for turns, game and noise
36-
but these can be overidden if desired.
36+
but these can be overridden if desired.
3737
"""
3838
self.result = []
3939
self.turns = turns
@@ -78,7 +78,7 @@ def players(self, players):
7878
def _stochastic(self):
7979
"""
8080
A boolean to show whether a match between two players would be
81-
stochastic
81+
stochastic.
8282
"""
8383
return is_stochastic(self.players, self.noise)
8484

axelrod/random_.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def randrange(a, b):
2424
return a + int(r)
2525

2626

27-
def seed(seed):
27+
def seed(seed_):
2828
"""Sets a seed"""
29-
random.seed(seed)
30-
numpy.random.seed(seed)
29+
random.seed(seed_)
30+
numpy.random.seed(seed_)

axelrod/result_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ def build_payoffs(self):
296296
297297
[uij1, uij2, ..., uijk]
298298
299-
Where k is the number of repetitions and uijk is the list of utilities
300-
obtained by player i against player j in each repetition.
299+
Where k is the number of repetitions and uijk is the list of
300+
utilities obtained by player i against player j in each repetition.
301301
"""
302302
plist = list(range(self.nplayers))
303303
payoffs = [[[] for opponent in plist] for player in plist]

axelrod/strategy_transformers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@ def __call__(self, PlayerClass):
6666
Returns
6767
-------
6868
new_class, class object
69-
A class object that can create instances of the modified PlayerClass
69+
A class object that can create instances of the modified
70+
PlayerClass
7071
"""
7172

7273
args = self.args
7374
kwargs = self.kwargs
7475
try:
75-
#if "name_prefix" in kwargs remove as only want dec arguments
76+
# if "name_prefix" in kwargs remove as only want dec arguments
7677
del kwargs["name_prefix"]
7778
except KeyError:
7879
pass

0 commit comments

Comments
 (0)