Strategies index

Here are the docstrings of all the strategies in the library.

class axelrod.strategies.adaptive.Adaptive(initial_plays: typing.List=None) → None[source]

Start with a specific sequence of C and D, then play the strategy that has worked best, recalculated each turn.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': {'game'}, 'inspects_source': False}
name = 'Adaptive'
reset()[source]
score_last_round(opponent: axelrod.player.Player)[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.alternator.Alternator[source]

A player who alternates between cooperating and defecting.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Alternator'
strategy(opponent: axelrod.player.Player) → str[source]

Artificial Neural Network based strategy.

# Original Source: https://gist.github.com/mojones/550b32c46a8169bb3cd89d917b73111a#file-ann-strategy-test-L60 # Original Author: Martin Jones, @mojones

class axelrod.strategies.ann.ANN(weights, num_features, num_hidden)[source]

A single layer neural network based strategy, with the following features: * Opponent’s first move is C * Opponent’s first move is D * Opponent’s second move is C * Opponent’s second move is D * Player’s previous move is C * Player’s previous move is D * Player’s second previous move is C * Player’s second previous move is D * Opponent’s previous move is C * Opponent’s previous move is D * Opponent’s second previous move is C * Opponent’s second previous move is D * Total opponent cooperations * Total opponent defections * Total player cooperations * Total player defections * Round number

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'ANN'
strategy(opponent)[source]
class axelrod.strategies.ann.EvolvedANN[source]

A strategy based on a pre-trained neural network with 17 features and a hidden layer of size 10.

Names:

  • Evolved ANN: Original name by Martin Jones.
name = 'Evolved ANN'
class axelrod.strategies.ann.EvolvedANN5[source]

A strategy based on a pre-trained neural network with 17 features and a hidden layer of size 5.

Names:

  • Evolved ANN 5: Original name by Marc Harper.
name = 'Evolved ANN 5'
class axelrod.strategies.ann.EvolvedANNNoise05[source]

A strategy based on a pre-trained neural network with a hidden layer of size 10, trained with noise=0.05.

Names:

  • Evolved ANN Noise 05: Original name by Marc Harper.
name = 'Evolved ANN 5 Noise 05'
axelrod.strategies.ann.activate(bias, hidden, output, inputs)[source]
Compute the output of the neural network:
output = relu(inputs * hidden_weights + bias) * output_weights
axelrod.strategies.ann.compute_features(player, opponent)[source]

Compute history features for Neural Network: * Opponent’s first move is C * Opponent’s first move is D * Opponent’s second move is C * Opponent’s second move is D * Player’s previous move is C * Player’s previous move is D * Player’s second previous move is C * Player’s second previous move is D * Opponent’s previous move is C * Opponent’s previous move is D * Opponent’s second previous move is C * Opponent’s second previous move is D * Total opponent cooperations * Total opponent defections * Total player cooperations * Total player defections * Round number

axelrod.strategies.ann.split_weights(weights, num_features, num_hidden)[source]

Splits the input vector into the the NN bias weights and layer parameters.

class axelrod.strategies.apavlov.APavlov2006 → None[source]

APavlov as defined in http://www.cs.nott.ac.uk/~pszjl/index_files/chapter4.pdf (pages 10-11).

APavlov attempts to classify its opponent as one of five strategies: Cooperative, ALLD, STFT, PavlovD, or Random. APavlov then responds in a manner intended to achieve mutual cooperation or to defect against uncooperative opponents.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Adaptive Pavlov 2006'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.apavlov.APavlov2011 → None[source]

APavlov as defined in http://www.graham-kendall.com/papers/lhk2011.pdf, as closely as can be determined.

APavlov attempts to classify its opponent as one of four strategies: Cooperative, ALLD, STFT, or Random. APavlov then responds in a manner intended to achieve mutual cooperation or to defect against uncooperative opponents.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Adaptive Pavlov 2011'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.appeaser.Appeaser[source]

A player who tries to guess what the opponent wants.

Switch the classifier every time the opponent plays ‘D’. Start with ‘C’, switch between ‘C’ and ‘D’ when opponent plays ‘D’.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Appeaser'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.averagecopier.AverageCopier[source]

The player will cooperate with probability p if the opponent’s cooperation ratio is p. Starts with random decision.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Average Copier'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.averagecopier.NiceAverageCopier[source]

Same as Average Copier, but always starts by cooperating.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Nice Average Copier'
strategy(opponent: axelrod.player.Player) → str[source]

Additional strategies from Axelrod’s first tournament.

class axelrod.strategies.axelrod_first.Davis(rounds_to_cooperate=10)[source]

Submitted to Axelrod’s first tournament by Morton Davis.

A player starts by cooperating for 10 rounds then plays Grudger, defecting if at any point the opponent has defected.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Davis'
strategy(opponent)[source]

Begins by playing C, then plays D for the remaining rounds if the opponent ever plays D.

class axelrod.strategies.axelrod_first.Feld(start_coop_prob=1.0, end_coop_prob=0.5, rounds_of_decay=200)[source]

Submitted to Axelrod’s first tournament by Scott Feld.

Defects when opponent defects. Cooperates with a probability that decreases to 0.5 at round 200.

Names:

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 200, 'makes_use_of': set(), 'inspects_source': False}
name = 'Feld'
strategy(opponent)[source]
class axelrod.strategies.axelrod_first.Grofman[source]

Submitted to Axelrod’s first tournament by Bernard Grofman.

Cooperate on the first 2 moves. Return opponent’s move for the next 5. Then cooperate if the last round’s moves were the same, otherwise cooperate with probability 2/7.

Names:

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Grofman'
strategy(opponent)[source]
class axelrod.strategies.axelrod_first.Joss(p=0.9)[source]

Submitted to Axelrod’s first tournament by Johann Joss.

Cooperates with probability 0.9 when the opponent cooperates, otherwise emulates Tit-For-Tat.

Names:

name = 'Joss'
class axelrod.strategies.axelrod_first.Nydegger[source]

Submitted to Axelrod’s first tournament by Rudy Nydegger.

The program begins with tit for tat for the first three moves, except that if it was the only one to cooperate on the first move and the only one to defect on the second move, it defects on the third move. After the third move, its choice is determined from the 3 preceding outcomes in the following manner.

Let A be the sum formed by counting the other’s defection as 2 points and one’s own as 1 point, and giving weights of 16, 4, and 1 to the preceding three moves in chronological order. The choice can be described as defecting only when A equals 1, 6, 7, 17, 22, 23, 26, 29, 30, 31, 33, 38, 39, 45, 49, 54, 55, 58, or 61.

Thus if all three preceding moves are mutual defection, A = 63 and the rule cooperates. This rule was designed for use in laboratory experiments as a stooge which had a memory and appeared to be trustworthy, potentially cooperative, but not gullible.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 3, 'makes_use_of': set(), 'inspects_source': False}
name = 'Nydegger'
static score_history(my_history, opponent_history, score_map)[source]

Implements the Nydegger formula A = 16 a_1 + 4 a_2 + a_3

strategy(opponent)[source]
class axelrod.strategies.axelrod_first.RevisedDowning(revised=True)[source]

Revised Downing attempts to determine if players are cooperative or not. If so, it cooperates with them. This strategy would have won Axelrod’s first tournament.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Revised Downing'
reset()[source]
strategy(opponent)[source]
class axelrod.strategies.axelrod_first.Shubik[source]

Submitted to Axelrod’s first tournament by Martin Shubik.

Plays like Tit-For-Tat with the following modification. After each retaliation, the number of rounds that Shubik retaliates increases by 1.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Shubik'
reset()[source]
strategy(opponent)[source]
class axelrod.strategies.axelrod_first.Tullock(rounds_to_cooperate=11)[source]

Submitted to Axelrod’s first tournament by Gordon Tullock.

Cooperates for the first 11 rounds then randomly cooperates 10% less often than the opponent has in previous rounds.

Names:

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 11, 'makes_use_of': set(), 'inspects_source': False}
memory_depth = 11
name = 'Tullock'
strategy(opponent)[source]
class axelrod.strategies.axelrod_first.UnnamedStrategy[source]

Apparently written by a grad student in political science whose name was withheld, this strategy cooperates with a given probability P. This probability (which has initial value .3) is updated every 10 rounds based on whether the opponent seems to be random, very cooperative or very uncooperative. Furthermore, if after round 130 the strategy is losing then P is also adjusted.

Fourteenth Place with 282.2 points is a 77-line program by a graduate student of political science whose dissertation is in game theory. This rule has a probability of cooperating, P, which is initially 30% and is updated every 10 moves. P is adjusted if the other player seems random, very cooperative, or very uncooperative. P is also adjusted after move 130 if the rule has a lower score than the other player. Unfortunately, the complex process of adjustment frequently left the probability of cooperation in the 30% to 70% range, and therefore the rule appeared random to many other players.

Names:

Warning: This strategy is not identical to the original strategy (source unavailable) and was written based on published descriptions.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 0, 'makes_use_of': set(), 'inspects_source': False}
name = 'Unnamed Strategy'
static strategy(opponent)[source]

Additional strategies from Axelrod’s second tournament.

class axelrod.strategies.axelrod_second.Champion[source]

Strategy submitted to Axelrod’s second tournament by Danny Champion.

This player cooperates on the first 10 moves and plays Tit for Tat for the next 15 more moves. After 25 moves, the program cooperates unless all the following are true: the other player defected on the previous move, the other player cooperated less than 60% and the random number between 0 and 1 is greater that the other player’s cooperation rate.

Names:

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': {'length'}, 'inspects_source': False}
name = 'Champion'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.axelrod_second.Eatherley[source]

Strategy submitted to Axelrod’s second tournament by Graham Eatherley.

A player that keeps track of how many times in the game the other player defected. After the other player defects, it defects with a probability equal to the ratio of the other’s total defections to the total moves to that point.

Names:

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Eatherley'
static strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.axelrod_second.Tester → None[source]

Submitted to Axelrod’s second tournament by David Gladstein.

Defects on the first move and plays Tit For Tat if the opponent ever defects (after one apology cooperation round). Otherwise alternate cooperation and defection.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Tester'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.backstabber.BackStabber[source]
name = 'BackStabber'
original_class

alias of BackStabber

strategy(opponent)
class axelrod.strategies.backstabber.DoubleCrosser[source]
name = 'DoubleCrosser'
original_class

alias of DoubleCrosser

strategy(opponent)
class axelrod.strategies.better_and_better.BetterAndBetter[source]

Defects with probability of ‘(1000 - current turn) / 1000’. Therefore it is less and less likely to defect as the round goes on.

Names:
classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Better and Better'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.calculator.Calculator → None[source]

Plays like (Hard) Joss for the first 20 rounds. If periodic behavior is detected, defect forever. Otherwise play TFT.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
extended_strategy(opponent: axelrod.player.Player) → str[source]
name = 'Calculator'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.cooperator.Cooperator[source]

A player who only ever cooperates.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 0, 'makes_use_of': set(), 'inspects_source': False}
name = 'Cooperator'
static strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.cooperator.TrickyCooperator[source]

A cooperator that is trying to be tricky.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 10, 'makes_use_of': set(), 'inspects_source': False}
name = 'Tricky Cooperator'
static strategy(opponent: axelrod.player.Player) → str[source]

Almost always cooperates, but will try to trick the opponent by defecting.

Defect once in a while in order to get a better payout, when the opponent has not defected in the last ten turns and only cooperated during last 3 turns.

class axelrod.strategies.cycler.AntiCycler → None[source]

A player that follows a sequence of plays that contains no cycles: C CD CCD CCCD CCCCD CCCCCD ...

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'AntiCycler'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.cycler.Cycler(cycle='CCD') → None[source]

A player that repeats a given sequence indefinitely.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Cycler'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.cycler.CyclerCCCCCD(cycle='CCCCCD') → None[source]
classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 5, 'makes_use_of': set(), 'stochastic': False}
name = 'Cycler CCCCCD'
class axelrod.strategies.cycler.CyclerCCCD(cycle='CCCD') → None[source]
classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 3, 'makes_use_of': set(), 'stochastic': False}
name = 'Cycler CCCD'
class axelrod.strategies.cycler.CyclerCCCDCD(cycle='CCCDCD') → None[source]
classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 5, 'makes_use_of': set(), 'stochastic': False}
name = 'Cycler CCCDCD'
class axelrod.strategies.cycler.CyclerCCD(cycle='CCD') → None[source]
classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 2, 'makes_use_of': set(), 'stochastic': False}
name = 'Cycler CCD'
class axelrod.strategies.cycler.CyclerDC(cycle='DC') → None[source]
classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'stochastic': False}
name = 'Cycler DC'
class axelrod.strategies.cycler.CyclerDDC(cycle='DDC') → None[source]
classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 2, 'makes_use_of': set(), 'stochastic': False}
name = 'Cycler DDC'
class axelrod.strategies.darwin.Darwin → None[source]

A strategy which accumulates a record (the ‘genome’) of what the most favourable response in the previous round should have been, and naively assumes that this will remain the correct response at the same round of future trials.

This ‘genome’ is preserved between opponents, rounds and repetitions of the tournament. It becomes a characteristic of the type and so a single version of this is shared by all instances for each loading of the class.

As this results in information being preserved between tournaments, this is classified as a cheating strategy!

If no record yet exists, the opponent’s response from the previous round is returned.

classifier = {'manipulates_state': True, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
genome = ['C']
mutate(outcome, trial)[source]

Select response according to outcome.

name = 'Darwin'
receive_match_attributes()[source]
reset()[source]

Reset instance properties.

strategy(opponent: axelrod.player.Player) → str[source]
valid_callers = ['play']
class axelrod.strategies.defector.Defector[source]

A player who only ever defects.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 0, 'makes_use_of': set(), 'inspects_source': False}
name = 'Defector'
static strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.defector.TrickyDefector[source]

A defector that is trying to be tricky.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Tricky Defector'
strategy(opponent: axelrod.player.Player) → str[source]

Almost always defects, but will try to trick the opponent into cooperating.

Defect if opponent has cooperated at least once in the past and has defected for the last 3 turns in a row.

class axelrod.strategies.doubler.Doubler[source]

Cooperates except when the opponent has defected and the opponent’s cooperation count is less than twice their defection count.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Doubler'
strategy(opponent)[source]
class axelrod.strategies.finite_state_machines.EvolvedFSM16[source]

A 16 state FSM player trained with an evolutionary algorithm.

Names:

  • Evolved FSM 16: Original name by Marc Harper
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 16, 'makes_use_of': set(), 'inspects_source': False}
name = 'Evolved FSM 16'
class axelrod.strategies.finite_state_machines.EvolvedFSM16Noise05[source]

A 16 state FSM player trained with an evolutionary algorithm with noisy matches (noise=0.05).

Names:

  • Evolved FSM 16 Noise 05: Original name by Marc Harper
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 16, 'makes_use_of': set(), 'inspects_source': False}
name = 'Evolved FSM 16 Noise 05'
class axelrod.strategies.finite_state_machines.EvolvedFSM4[source]

A 4 state FSM player trained with an evolutionary algorithm.

Names:

  • Evolved FSM 4: Original name by Marc Harper
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 4, 'makes_use_of': set(), 'inspects_source': False}
name = 'Evolved FSM 4'
class axelrod.strategies.finite_state_machines.FSMPlayer(transitions=None, initial_state=None, initial_action=None)[source]

Abstract base class for finite state machine players.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'FSM Player'
reset()[source]
strategy(opponent)[source]
class axelrod.strategies.finite_state_machines.Fortress3[source]

Finite state machine player specified in DOI:10.1109/CEC.2006.1688322. Note that the description in http://www.graham-kendall.com/papers/lhk2011.pdf is not correct.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 3, 'makes_use_of': set(), 'inspects_source': False}
name = 'Fortress3'
class axelrod.strategies.finite_state_machines.Fortress4[source]

Finite state machine player specified in DOI:10.1109/CEC.2006.1688322. Note that the description in http://www.graham-kendall.com/papers/lhk2011.pdf is not correct.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 4, 'makes_use_of': set(), 'inspects_source': False}
name = 'Fortress4'
class axelrod.strategies.finite_state_machines.Predator[source]

Finite state machine player specified in DOI:10.1109/CEC.2006.1688322.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 9, 'makes_use_of': set(), 'inspects_source': False}
name = 'Predator'
class axelrod.strategies.finite_state_machines.Pun1[source]

FSM player described in [Ashlock2006].

Names:
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 2, 'makes_use_of': set(), 'inspects_source': False}
name = 'Pun1'
class axelrod.strategies.finite_state_machines.Raider[source]

FSM player described in DOI:10.1109/FOCI.2014.7007818

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 3, 'makes_use_of': set(), 'inspects_source': False}
name = 'Raider'
class axelrod.strategies.finite_state_machines.Ripoff[source]

FSM player described in DOI:10.1109/TEVC.2008.920675.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 2, 'makes_use_of': set(), 'inspects_source': False}
name = 'Ripoff'
class axelrod.strategies.finite_state_machines.SimpleFSM(transitions, initial_state)[source]

Simple implementation of a finite state machine that transitions between states based on the last round of play.

https://en.wikipedia.org/wiki/Finite-state_machine

move(opponent_action)[source]

Computes the response move and changes state.

class axelrod.strategies.finite_state_machines.SolutionB1[source]

FSM player described in DOI:10.1109/TCIAIG.2014.2326012.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 3, 'makes_use_of': set(), 'inspects_source': False}
name = 'SolutionB1'
class axelrod.strategies.finite_state_machines.SolutionB5[source]

FSM player described in DOI:10.1109/TCIAIG.2014.2326012.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 5, 'makes_use_of': set(), 'inspects_source': False}
name = 'SolutionB5'
class axelrod.strategies.finite_state_machines.Thumper[source]

FSM player described in DOI:10.1109/TEVC.2008.920675.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 2, 'makes_use_of': set(), 'inspects_source': False}
name = 'Thumper'
class axelrod.strategies.forgiver.Forgiver[source]

A player starts by cooperating however will defect if at any point the opponent has defected more than 10 percent of the time

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Forgiver'
strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing C, then plays D if the opponent has defected more than 10 percent of the time

class axelrod.strategies.forgiver.ForgivingTitForTat[source]

A player starts by cooperating however will defect if at any point, the opponent has defected more than 10 percent of the time, and their most recent decision was defect.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Forgiving Tit For Tat'
strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing C, then plays D if, the opponent has defected more than 10 percent of the time, and their most recent decision was defect.

Stochastic variants of Lookup table based-strategies, trained with particle swarm algorithms.

For the original see:
https://gist.github.com/GDKO/60c3d0fd423598f3c4e4
class axelrod.strategies.gambler.Gambler(lookup_table=None, initial_actions=None, lookup_pattern=None, parameters=None)[source]

A stochastic version of LookerUp which will select randomly an action in some cases.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Gambler'
strategy(opponent)[source]
class axelrod.strategies.gambler.PSOGambler1_1_1[source]

A 1x1x1 PSOGambler trained with pyswarm.

Names:
  • PSO Gambler 1_1_1: Original name by Marc Harper
name = 'PSO Gambler 1_1_1'
class axelrod.strategies.gambler.PSOGambler2_2_2[source]

A 2x2x2 PSOGambler trained with pyswarm. Original version by @GDKO.

Names:
  • PSO Gambler 2_2_2: Original name by Marc Harper
name = 'PSO Gambler 2_2_2'
class axelrod.strategies.gambler.PSOGambler2_2_2_Noise05[source]

A 2x2x2 PSOGambler trained with pyswarm with noise=0.05.

Names:
  • PSO Gambler 2_2_2 Noise 05: Original name by Marc Harper
name = 'PSO Gambler 2_2_2 Noise 05'
class axelrod.strategies.gambler.PSOGamblerMem1[source]

A 1x1x0 PSOGambler trained with pyswarm. This is the ‘optimal’ memory one strategy trained against the set of short run time strategies in the Axelrod library.

Names:
  • PSO Gambler Mem1: Original name by Marc Harper
name = 'PSO Gambler Mem1'
class axelrod.strategies.geller.Geller[source]

Observes what the player will do in the next round and adjust.

If unable to do this: will play randomly.

Geller - by Martin Chorley (@martinjc), heavily inspired by Matthew Williams (@voxmjw)

This code is inspired by Matthew Williams’ talk “Cheating at rock-paper-scissors — meta-programming in Python” given at Django Weekend Cardiff in February 2014.

His code is here: https://github.com/mattjw/rps_metaprogramming and there’s some more info here: http://www.mattjw.net/2014/02/rps-metaprogramming/

This code is way simpler than Matt’s, as in this exercise we already have access to the opponent instance, so don’t need to go hunting for it in the stack. Instead we can just call it to see what it’s going to play, and return a result based on that

This is almost certainly cheating, and more than likely against the spirit of the ‘competition’ :-)

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': -1, 'makes_use_of': set(), 'inspects_source': True}
default()
name = 'Geller'
strategy(opponent: axelrod.player.Player) → str[source]

Look at what the opponent will play in the next round and choose a strategy that gives the least jail time, which is is equivalent to playing the same strategy as that which the opponent will play.

class axelrod.strategies.geller.GellerCooperator[source]

Observes what the payer will do (like Geller) but if unable to will cooperate.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': -1, 'makes_use_of': set(), 'inspects_source': True}
default()
name = 'Geller Cooperator'
class axelrod.strategies.geller.GellerDefector[source]

Observes what the payer will do (like Geller) but if unable to will defect.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': -1, 'makes_use_of': set(), 'inspects_source': True}
default()
name = 'Geller Defector'
class axelrod.strategies.gobymajority.GoByMajority(memory_depth=inf, soft=True)[source]

A player examines the history of the opponent: if the opponent has more defections than cooperations then the player defects.

In case of equal number of defections and cooperations this player will Cooperate. Passing the soft=False keyword argument when initialising will create a HardGoByMajority which Defects in case of equality.

An optional memory attribute will limit the number of turns remembered (by default this is 0)

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Go By Marjority'
strategy(opponent)[source]

This is affected by the history of the opponent.

As long as the opponent cooperates at least as often as they defect then the player will cooperate. If at any point the opponent has more defections than cooperations in memory the player defects.

class axelrod.strategies.gobymajority.GoByMajority10(memory_depth=10, soft=True)[source]

GoByMajority player with a memory of 10.

classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 10, 'makes_use_of': set(), 'stochastic': False}
name = 'Go By Majority 10'
class axelrod.strategies.gobymajority.GoByMajority20(memory_depth=20, soft=True)[source]

GoByMajority player with a memory of 20.

classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 20, 'makes_use_of': set(), 'stochastic': False}
name = 'Go By Majority 20'
class axelrod.strategies.gobymajority.GoByMajority40(memory_depth=40, soft=True)[source]

GoByMajority player with a memory of 40.

classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 40, 'makes_use_of': set(), 'stochastic': False}
name = 'Go By Majority 40'
class axelrod.strategies.gobymajority.GoByMajority5(memory_depth=5, soft=True)[source]

GoByMajority player with a memory of 5.

classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 5, 'makes_use_of': set(), 'stochastic': False}
name = 'Go By Majority 5'
class axelrod.strategies.gobymajority.HardGoByMajority(memory_depth=inf, soft=False)[source]

A player examines the history of the opponent: if the opponent has more defections than cooperations then the player defects. In case of equal number of defections and cooperations this player will Defect.

An optional memory attribute will limit the number of turns remembered (by default this is 0)

name = 'Hard Go By Majority'
class axelrod.strategies.gobymajority.HardGoByMajority10(memory_depth=10, soft=False)[source]

HardGoByMajority player with a memory of 10.

classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 10, 'makes_use_of': set(), 'stochastic': False}
name = 'Hard Go By Majority 10'
class axelrod.strategies.gobymajority.HardGoByMajority20(memory_depth=20, soft=False)[source]

HardGoByMajority player with a memory of 20.

classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 20, 'makes_use_of': set(), 'stochastic': False}
name = 'Hard Go By Majority 20'
class axelrod.strategies.gobymajority.HardGoByMajority40(memory_depth=40, soft=False)[source]

HardGoByMajority player with a memory of 40.

classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 40, 'makes_use_of': set(), 'stochastic': False}
name = 'Hard Go By Majority 40'
class axelrod.strategies.gobymajority.HardGoByMajority5(memory_depth=5, soft=False)[source]

HardGoByMajority player with a memory of 5.

classifier = {'manipulates_state': False, 'inspects_source': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 5, 'makes_use_of': set(), 'stochastic': False}
name = 'Hard Go By Majority 5'
class axelrod.strategies.gradualkiller.GradualKiller[source]
name = 'Gradual Killer'
original_class

alias of GradualKiller

strategy(opponent)
class axelrod.strategies.grudger.Aggravater[source]

Grudger, except that it defects on the first 3 turns

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Aggravater'
static strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.grudger.EasyGo[source]

A player starts by defecting however will cooperate if at any point the opponent has defected.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'EasyGo'
static strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing D, then plays C for the remaining rounds if the opponent ever plays D.

class axelrod.strategies.grudger.ForgetfulGrudger → None[source]

A player starts by cooperating however will defect if at any point the opponent has defected, but forgets after mem_length matches.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 10, 'makes_use_of': set(), 'inspects_source': False}
name = 'Forgetful Grudger'
reset()[source]

Resets scores and history.

strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing C, then plays D for mem_length rounds if the opponent ever plays D.

class axelrod.strategies.grudger.Grudger[source]

A player starts by cooperating however will defect if at any point the opponent has defected.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Grudger'
static strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing C, then plays D for the remaining rounds if the opponent ever plays D.

class axelrod.strategies.grudger.GrudgerAlternator[source]

A player starts by cooperating until the first opponents defection, then alternates D-C.

Names:

  • c_then_per_dc: [PRISON1998]
  • Grudger Alternator: Original name by Geraint Palmer
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'GrudgerAlternator'
strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing C, then plays Alternator for the remaining rounds if the opponent ever plays D.

class axelrod.strategies.grudger.OppositeGrudger[source]

A player starts by defecting however will cooperate if at any point the opponent has cooperated.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Opposite Grudger'
static strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing D, then plays C for the remaining rounds if the opponent ever plays C.

class axelrod.strategies.grudger.SoftGrudger → None[source]

A modification of the Grudger strategy. Instead of punishing by always defecting: punishes by playing: D, D, D, D, C, C. (Will continue to cooperate afterwards).

For reference see: “Engineering Design of Strategies for Winning Iterated Prisoner’s Dilemma Competitions” by Jiawei Li, Philip Hingston, and Graham Kendall. IEEE TRANSACTIONS ON COMPUTATIONAL INTELLIGENCE AND AI IN GAMES, VOL. 3, NO. 4, DECEMBER 2011

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 6, 'makes_use_of': set(), 'inspects_source': False}
name = 'Soft Grudger'
reset()[source]

Resets scores and history.

strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing C, then plays D, D, D, D, C, C against a defection

class axelrod.strategies.grumpy.Grumpy(starting_state: str='Nice', grumpy_threshold: int=10, nice_threshold: int=-10) → None[source]

A player that defects after a certain level of grumpiness. Grumpiness increases when the opponent defects and decreases when the opponent co-operates.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Grumpy'
reset()[source]

Resets score, history and state for the next round of the tournament.

strategy(opponent: axelrod.player.Player) → str[source]

A player that gets grumpier the more the opposition defects, and nicer the more they cooperate.

Starts off Nice, but becomes grumpy once the grumpiness threshold is hit. Won’t become nice once that grumpy threshold is hit, but must reach a much lower threshold before it becomes nice again.

class axelrod.strategies.handshake.Handshake(initial_plays: typing.List=None) → None[source]

Starts with C, D. If the opponent plays the same way, cooperate forever, else defect forever.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Handshake'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.hunter.AlternatorHunter → None[source]

A player who hunts for alternators.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Alternator Hunter'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.hunter.CooperatorHunter[source]

A player who hunts for cooperators.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Cooperator Hunter'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.hunter.CycleHunter → None[source]

Hunts strategies that play cyclically, like any of the Cyclers, Alternator, etc.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Cycle Hunter'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.hunter.DefectorHunter[source]

A player who hunts for defectors.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Defector Hunter'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.hunter.EventualCycleHunter → None[source]

Hunts strategies that eventually play cyclically.

name = 'Eventual Cycle Hunter'
strategy(opponent: axelrod.player.Player) → None[source]
class axelrod.strategies.hunter.MathConstantHunter[source]

A player who hunts for mathematical constant players.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Math Constant Hunter'
strategy(opponent: axelrod.player.Player) → str[source]

Check whether the number of cooperations in the first and second halves of the history are close. The variance of the uniform distribution (1/4) is a reasonable delta but use something lower for certainty and avoiding false positives. This approach will also detect a lot of random players.

class axelrod.strategies.hunter.RandomHunter → None[source]

A player who hunts for random players.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Random Hunter'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]

A random player is unpredictable, which means the conditional frequency of cooperation after cooperation, and defection after defections, should be close to 50%... although how close is debatable.

axelrod.strategies.hunter.is_alternator(history: typing.List) → bool[source]
class axelrod.strategies.inverse.Inverse[source]

A player who defects with a probability that diminishes relative to how long ago the opponent defected.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Inverse'
static strategy(opponent: axelrod.player.Player) → str[source]

Looks at opponent history to see if they have defected.

If so, player defection is inversely proportional to when this occurred.

class axelrod.strategies.lookerup.EvolvedLookerUp1_1_1[source]

A 1 1 1 Lookerup trained with an evolutionary algorithm.

Names:
  • Evolved Lookerup 1 1 1: Original name by Marc Harper
name = 'EvolvedLookerUp1_1_1'
class axelrod.strategies.lookerup.EvolvedLookerUp2_2_2[source]

A 2 2 2 Lookerup trained with an evolutionary algorithm.

Names:
  • Evolved Lookerup 2 2 2: Original name by Marc Harper
name = 'EvolvedLookerUp2_2_2'
class axelrod.strategies.lookerup.LookerUp(lookup_table=None, initial_actions=None, lookup_pattern=None, parameters=None)[source]

A strategy that uses a lookup table to decide what to do based on a combination of the last m1 plays, m2 opponent plays, and the opponent’s opening n actions. If there isn’t enough history to do this (i.e. for the first m1 or m2 turns) then cooperate.

The lookup table is implemented as a dict. The keys are 3-tuples giving the opponents first n actions, self’s last m1 actions, and opponents last m2 actions, all as strings. The values are the actions to play on this round.

For example, in the case of m1=m2=n=1, if - the opponent started by playing C - my last action was a C the opponents - last action was a D then the corresponding key would be

(‘C’, ‘C’, ‘D’)

and the value would contain the action to play on this turn.

Some well-known strategies can be expressed as special cases; for example Cooperator is given by the dict:

{('', '', '') : C}

where m and n are both zero. Tit-For-Tat is given by:

{('', 'C', 'D'): D,
 ('', 'D', 'D'): D,
 ('', 'C', 'C'): C,
 ('', 'D', 'C'): C}

where m=1 and n=0.

Lookup tables where the action depends on the opponent’s first actions (as opposed to most recent actions) will have a non-empty first string in the tuple. For example, this fragment of a dict:

{('C', 'C', 'C'): C,
 ('D', 'C', 'C'): D}

states that if self and opponent both cooperated on the previous turn, we should cooperate this turn unless the opponent started by defecting, in which case we should defect.

To denote lookup tables where the action depends on sequences of actions (so m or n are greater than 1), simply concatenate the strings together.

Below is an incomplete example where m1=m2=3 and n=2.

{(‘CC’, ‘CDD’, ‘CCC’): C,
(‘CD’, ‘CCD’, ‘CCC’): D}
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'LookerUp'
strategy(opponent)[source]
class axelrod.strategies.lookerup.Winner12[source]

A lookup table based strategy.

Names:
name = 'Winner12'
class axelrod.strategies.lookerup.Winner21[source]

A lookup table based strategy.

Names:
name = 'Winner21'
axelrod.strategies.lookerup.create_lookup_table_from_pattern(plays, op_plays, op_start_plays, pattern)[source]
axelrod.strategies.lookerup.create_lookup_table_keys(plays, op_plays, op_start_plays)[source]

Creates the keys for a lookup table.

class axelrod.strategies.mathematicalconstants.CotoDeRatio[source]

The player will always aim to bring the ratio of co-operations to defections closer to the ratio as given in a sub class

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
strategy(opponent)[source]
class axelrod.strategies.mathematicalconstants.Golden[source]

The player will always aim to bring the ratio of co-operations to defections closer to the golden mean

name = '$\\phi$'
ratio = 1.618033988749895
class axelrod.strategies.mathematicalconstants.Pi[source]

The player will always aim to bring the ratio of co-operations to defections closer to the pi

name = '$\\pi$'
ratio = 3.141592653589793
class axelrod.strategies.mathematicalconstants.e[source]

The player will always aim to bring the ratio of co-operations to defections closer to the e

name = '$e$'
ratio = 2.718281828459045
class axelrod.strategies.memoryone.ALLCorALLD[source]

This strategy is at the parameter extreme of the ZD strategies (phi = 0). It simply repeats its last move, and so mimics ALLC or ALLD after round one. If the tournament is noisy, there will be long runs of C and D.

For now starting choice is random of 0.6, but that was an arbitrary choice at implementation time.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'ALLCorALLD'
strategy(opponent)[source]
class axelrod.strategies.memoryone.FirmButFair[source]

A strategy that cooperates on the first move, and cooperates except after receiving a sucker payoff.

Names:

name = 'Firm But Fair'
class axelrod.strategies.memoryone.GTFT(p=None)[source]

Generous Tit For Tat Strategy.

Names:

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': {'game'}, 'inspects_source': False}
name = 'GTFT'
receive_match_attributes()[source]
class axelrod.strategies.memoryone.LRPlayer(four_vector=None, initial='C')[source]

Abstraction for Linear Relation players. These players enforce a linear difference in stationary payoffs s * (S_xy - l) = S_yx - l, with 0 <= l <= R. The parameter s is called the slope and the parameter l the baseline payoff. For extortionate strategies, the extortion factor is the inverse of the slope.

This parameterization is Equation 14 in http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0077886. See Figure 2 of the article for a more in-depth explanation.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': {'game'}, 'inspects_source': False}
name = 'LinearRelation'
receive_match_attributes(phi=0, s=None, l=None)[source]

Parameters

phi, s, l: floats
Parameter used to compute the four-vector according to the parameterization of the strategies below.
class axelrod.strategies.memoryone.MemoryOnePlayer(four_vector=None, initial='C')[source]

Uses a four-vector for strategies based on the last round of play, (P(C|CC), P(C|CD), P(C|DC), P(C|DD)), defaults to Win-Stay Lose-Shift. Intended to be used as an abstract base class or to at least be supplied with a initializing four_vector.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Generic Memory One Player'
set_four_vector(four_vector)[source]
strategy(opponent)[source]
class axelrod.strategies.memoryone.SoftJoss(q=0.9)[source]

Defects with probability 0.9 when the opponent defects, otherwise emulates Tit-For-Tat.

name = 'Soft Joss'
class axelrod.strategies.memoryone.StochasticCooperator[source]

Stochastic Cooperator, http://www.nature.com/ncomms/2013/130801/ncomms3193/full/ncomms3193.html.

name = 'Stochastic Cooperator'
class axelrod.strategies.memoryone.StochasticWSLS(ep=0.05)[source]

Stochastic WSLS, similar to Generous TFT

name = 'Stochastic WSLS'
class axelrod.strategies.memoryone.WinShiftLoseStay(initial='D')[source]

Win-Shift Lose-Stay, also called Reverse Pavlov.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Win-Shift Lose-Stay'
class axelrod.strategies.memoryone.WinStayLoseShift(initial='C')[source]

Win-Stay Lose-Shift, also called Pavlov.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Win-Stay Lose-Shift'
class axelrod.strategies.memoryone.ZDExtort2(phi=0.1111111111111111, s=0.5)[source]

An Extortionate Zero Determinant Strategy with l=P.

name = 'ZD-Extort-2'
receive_match_attributes()[source]
class axelrod.strategies.memoryone.ZDExtort2v2(phi=0.125, s=0.5, l=1)[source]

An Extortionate Zero Determinant Strategy with l=1.

name = 'ZD-Extort-2 v2'
receive_match_attributes()[source]
class axelrod.strategies.memoryone.ZDExtort4(phi=0.23529411764705882, s=0.25, l=1)[source]

An Extortionate Zero Determinant Strategy with l=1, s=1/4. TFT is the other extreme (with l=3, s=1)

name = 'ZD-Extort-4'
receive_match_attributes()[source]
class axelrod.strategies.memoryone.ZDGTFT2(phi=0.25, s=0.5)[source]

A Generous Zero Determinant Strategy with l=R.

name = 'ZD-GTFT-2'
receive_match_attributes()[source]
class axelrod.strategies.memoryone.ZDGen2(phi=0.125, s=0.5, l=3)[source]

A Generous Zero Determinant Strategy with l=3.

name = 'ZD-GEN-2'
receive_match_attributes()[source]
class axelrod.strategies.memoryone.ZDSet2(phi=0.25, s=0.0, l=2)[source]

A Generous Zero Determinant Strategy with l=2.

name = 'ZD-SET-2'
receive_match_attributes()[source]
class axelrod.strategies.meta.MetaHunter[source]

A player who uses a selection of hunters.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
static meta_strategy(results, opponent)[source]
name = 'Meta Hunter'
class axelrod.strategies.meta.MetaHunterAggressive[source]

A player who uses a selection of hunters.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
static meta_strategy(results, opponent)[source]
name = 'Meta Hunter Aggressive'
class axelrod.strategies.meta.MetaMajority(team=None)[source]

A player who goes by the majority vote of all other non-meta players.

static meta_strategy(results, opponent)[source]
name = 'Meta Majority'
class axelrod.strategies.meta.MetaMajorityFiniteMemory[source]

MetaMajority with the team of Finite Memory Players

name = 'Meta Majority Finite Memory'
class axelrod.strategies.meta.MetaMajorityLongMemory[source]

MetaMajority with the team of Long (infinite) Memory Players

name = 'Meta Majority Long Memory'
class axelrod.strategies.meta.MetaMajorityMemoryOne[source]

MetaMajority with the team of Memory One players

name = 'Meta Majority Memory One'
class axelrod.strategies.meta.MetaMinority(team=None)[source]

A player who goes by the minority vote of all other non-meta players.

static meta_strategy(results, opponent)[source]
name = 'Meta Minority'
class axelrod.strategies.meta.MetaMixer(team=None, distribution=None)[source]

A player who randomly switches between a team of players. If no distribution is passed then the player will uniformly choose between sub players.

In essence this is creating a Mixed strategy.

Parameters

team : list of strategy classes, optional
Team of strategies that are to be randomly played If none is passed will select the ordinary strategies.
distribution : list representing a probability distribution, optional
This gives the distribution from which to select the players. If none is passed will select uniformly.
classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': True, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
meta_strategy(results, opponent)[source]

Using the numpy.random choice function to sample with weights

name = 'Meta Mixer'
class axelrod.strategies.meta.MetaPlayer(team=None)[source]

A generic player that has its own team of players.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': True, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': {'length', 'game'}, 'inspects_source': False}
meta_strategy(results, opponent)[source]

Determine the meta result based on results of all players. Override this function in child classes.

name = 'Meta Player'
reset()[source]
strategy(opponent)[source]
class axelrod.strategies.meta.MetaWinner(team=None)[source]

A player who goes by the strategy of the current winner.

meta_strategy(results, opponent)[source]
name = 'Meta Winner'
reset()[source]
class axelrod.strategies.meta.MetaWinnerDeterministic[source]

Meta Winner with the team of Deterministic Players.

name = 'Meta Winner Deterministic'
class axelrod.strategies.meta.MetaWinnerEnsemble(team=None)[source]

A variant of MetaWinner that chooses one of the top scoring strategies at random against each opponent. Note this strategy is always stochastic regardless of the team.

Names:

Meta Winner Ensemble: Original name by Marc Harper

meta_strategy(results, opponent)[source]
name = 'Meta Winner Ensemble'
class axelrod.strategies.meta.MetaWinnerFiniteMemory[source]

MetaWinner with the team of Finite Memory Players

name = 'Meta Winner Finite Memory'
class axelrod.strategies.meta.MetaWinnerLongMemory[source]

MetaWinner with the team of Long (infinite) Memory Players

name = 'Meta Winner Long Memory'
class axelrod.strategies.meta.MetaWinnerMemoryOne[source]

MetaWinner with the team of Memory One players

name = 'Meta Winner Memory One'
class axelrod.strategies.meta.MetaWinnerStochastic[source]

Meta Winner with the team of Stochastic Players.

name = 'Meta Winner Stochastic'
class axelrod.strategies.meta.NMWEDeterministic[source]

Nice Meta Winner Ensemble with the team of Deterministic Players.

name = 'NMWE Deterministic'
class axelrod.strategies.meta.NMWEFiniteMemory[source]

Nice Meta Winner Ensemble with the team of Finite Memory Players.

name = 'NMWE Finite Memory'
class axelrod.strategies.meta.NMWELongMemory[source]

Nice Meta Winner Ensemble with the team of Long Memory Players.

name = 'NMWE Long Memory'
class axelrod.strategies.meta.NMWEMemoryOne[source]

Nice Meta Winner Ensemble with the team of Memory One Players.

name = 'NMWE Memory One'
class axelrod.strategies.meta.NMWEStochastic[source]

Nice Meta Winner Ensemble with the team of Stochastic Players.

name = 'NMWE Stochastic'
class axelrod.strategies.meta.NiceMetaWinner(team=None)
name = 'Nice Meta Winner'
original_class

alias of MetaWinner

strategy(opponent)
class axelrod.strategies.meta.NiceMetaWinnerEnsemble(team=None)
name = 'Nice Meta Winner Ensemble'
original_class

alias of MetaWinnerEnsemble

strategy(opponent)
class axelrod.strategies.mindcontrol.MindBender[source]

A player that changes the opponent’s strategy by modifying the internal dictionary.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': True, 'memory_depth': -10, 'makes_use_of': set(), 'inspects_source': False}
name = 'Mind Bender'
static strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.mindcontrol.MindController[source]

A player that changes the opponents strategy to cooperate.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': True, 'memory_depth': -10, 'makes_use_of': set(), 'inspects_source': False}
name = 'Mind Controller'
static strategy(opponent: axelrod.player.Player) → str[source]

Alters the opponents strategy method to be a lambda function which always returns C. This player will then always return D to take advantage of this

class axelrod.strategies.mindcontrol.MindWarper[source]

A player that changes the opponent’s strategy but blocks changes to its own.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': True, 'memory_depth': -10, 'makes_use_of': set(), 'inspects_source': False}
name = 'Mind Warper'
static strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.mindreader.MindReader[source]

A player that looks ahead at what the opponent will do and decides what to do.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': -10, 'makes_use_of': set(), 'inspects_source': True}
name = 'Mind Reader'
strategy(opponent: axelrod.player.Player) → str[source]

Pretends to play the opponent a number of times before each match. The primary purpose is to look far enough ahead to see if a defect will be punished by the opponent.

If the MindReader attempts to play itself (or another similar strategy), then it will cause a recursion loop, so this is also handled in this method, by defecting if the method is called by strategy

class axelrod.strategies.mindreader.MirrorMindReader[source]

A player that will mirror whatever strategy it is playing against by cheating and calling the opponent’s strategy function instead of its own.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': True, 'memory_depth': -10, 'makes_use_of': set(), 'inspects_source': True}
name = 'Mirror Mind Reader'
strategy(opponent: axelrod.player.Player) → str[source]

Will read the mind of the opponent and play the opponent’s strategy.

Also avoid infinite recursion when called by itself or another mind reader or bender by cooperating.

class axelrod.strategies.mindreader.ProtectedMindReader[source]

A player that looks ahead at what the opponent will do and decides what to do. It is also protected from mind control strategies

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': True, 'memory_depth': -10, 'makes_use_of': set(), 'inspects_source': True}
name = 'Protected Mind Reader'
class axelrod.strategies.mutual.Desperate[source]

A player that only cooperates after mutual defection.

Names:

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Desperate'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.mutual.Hopeless[source]

A player that only defects after mutual cooperation.

Names:

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Hopeless'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.mutual.Willing[source]

A player that only defects after mutual defection.

Names:

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Willing'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.negation.Negation[source]
A player starts by cooperating or defecting randomly if it’s their first move,
then simply doing the opposite of the opponents last move thereafter.

Names:

Negation - [http://www.prisoners-dilemma.com/competition.html]

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Negation'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.oncebitten.FoolMeForever[source]

Fool me once, shame on me. Teach a man to fool me and I’ll be fooled for the rest of my life.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Fool Me Forever'
static strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.oncebitten.FoolMeOnce[source]

Forgives one D then retaliates forever on a second D.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Fool Me Once'
static strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.oncebitten.ForgetfulFoolMeOnce(forget_probability: float=0.05) → None[source]

Forgives one D then retaliates forever on a second D. Sometimes randomly forgets the defection count, and so keeps a secondary count separate from the standard count in Player.

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Forgetful Fool Me Once'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.oncebitten.OnceBitten → None[source]

Cooperates once when the opponent defects, but if they defect twice in a row defaults to forgetful grudger for 10 turns defecting.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 12, 'makes_use_of': set(), 'inspects_source': False}
name = 'Once Bitten'
reset()[source]

Resets grudge memory and history.

strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing C, then plays D for mem_length rounds if the opponent ever plays D twice in a row.

class axelrod.strategies.prober.CollectiveStrategy[source]

Defined in [Li2009]. ‘It always cooperates in the first move and defects in the second move. If the opponent also cooperates in the first move and defects in the second move, CS will cooperate until the opponent defects. Otherwise, CS will always defect.’

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'CollectiveStrategy'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.prober.HardProber[source]

Plays D, D, C, C initially. Defects forever if opponent cooperated in moves 2 and 3. Otherwise plays TFT.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Hard Prober'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.prober.NaiveProber(p: axelrod.player.Player=0.1) → None[source]

Like tit-for-tat, but it occasionally defects with a small probability.

For reference see: “Engineering Design of Strategies for Winning Iterated Prisoner’s Dilemma Competitions” by Jiawei Li, Philip Hingston, and Graham Kendall. IEEE TRANSACTIONS ON COMPUTATIONAL INTELLIGENCE AND AI IN GAMES, VOL. 3, NO. 4, DECEMBER 2011

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Naive Prober'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.prober.Prober[source]

Plays D, C, C initially. Defects forever if opponent cooperated in moves 2 and 3. Otherwise plays TFT.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Prober'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.prober.Prober2[source]

Plays D, C, C initially. Cooperates forever if opponent played D then C in moves 2 and 3. Otherwise plays TFT.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Prober 2'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.prober.Prober3[source]

Plays D, C initially. Defects forever if opponent played C in moves 2. Otherwise plays TFT.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Prober 3'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.prober.Prober4 → None[source]

Plays C, C, D, C, D, D, D, C, C, D, C, D, C, C, D, C, D, D, C, D initially. Counts retaliating and provocative defections of the opponent. If the absolute difference between the counts is smaller or equal to 2, defects forever. Otherwise plays C for the next 5 turns and TFT for the rest of the game.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Prober 4'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.prober.RemorsefulProber(p: float=0.1) → None[source]

Like Naive Prober, but it remembers if the opponent responds to a random defection with a defection by being remorseful and cooperating.

For reference see: “Engineering Design of Strategies for Winning Iterated Prisoner’s Dilemma Competitions” by Jiawei Li, Philip Hingston, and Graham Kendall. IEEE TRANSACTIONS ON COMPUTATIONAL INTELLIGENCE AND AI IN GAMES, VOL. 3, NO. 4, DECEMBER 2011

A more complete description is given in “The Selfish Gene” (https://books.google.co.uk/books?id=ekonDAAAQBAJ):

“Remorseful Prober remembers whether it has just spontaneously defected, and whether the result was prompt retaliation. If so, it ‘remorsefully’ allows its opponent ‘one free hit’ without retaliating.”

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 2, 'makes_use_of': set(), 'inspects_source': False}
name = 'Remorseful Prober'
reset()[source]
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.punisher.InversePunisher → None[source]

An inverted version of Punisher. The player starts by cooperating however will defect if at any point the opponent has defected, and forgets after mem_length matches, with 1 <= mem_length <= 20. This time mem_length is proportional to the amount of time the opponent has played C.

Names:

  • Inverse Punisher: Original by Geraint Palmer
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Inverse Punisher'
reset()[source]

Resets internal variables and history

strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing C, then plays D for an amount of rounds proportional to the opponents historical ‘%’ of playing C if the opponent ever plays D.

class axelrod.strategies.punisher.LevelPunisher[source]

A player starts by cooperating however, after 10 rounds will defect if at any point the number of defections by an opponent is greater than 20%.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Level Punisher'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.punisher.Punisher → None[source]

A player starts by cooperating however will defect if at any point the opponent has defected, but forgets after meme_length matches, with 1<=mem_length<=20 proportional to the amount of time the opponent has played D, punishing that player for playing D too often.

Names:

  • Punisher: Original by Geraint Palmer
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Punisher'
reset()[source]

Resets scores and history

strategy(opponent: axelrod.player.Player) → str[source]

Begins by playing C, then plays D for an amount of rounds proportional to the opponents historical ‘%’ of playing D if the opponent ever plays D

class axelrod.strategies.qlearner.ArrogantQLearner[source]

A player who learns the best strategies through the q-learning algorithm.

This Q learner jumps to quick conclusions and cares about the future.

Names:

  • Arrogant Q Learner: Original strategy by Geraint Palmer
discount_rate = 0.1
learning_rate = 0.9
name = 'Arrogant QLearner'
class axelrod.strategies.qlearner.CautiousQLearner[source]

A player who learns the best strategies through the q-learning algorithm.

This Q learner is slower to come to conclusions and wants to look ahead more.

Names:

  • Cautious Q Learner: Original strategy by Geraint Palmer
discount_rate = 0.1
learning_rate = 0.1
name = 'Cautious QLearner'
class axelrod.strategies.qlearner.HesitantQLearner[source]

A player who learns the best strategies through the q-learning algorithm.

This Q learner is slower to come to conclusions and does not look ahead much.

Names:

  • Hesitant Q Learner: Original strategy by Geraint Palmer
discount_rate = 0.9
learning_rate = 0.1
name = 'Hesitant QLearner'
class axelrod.strategies.qlearner.RiskyQLearner[source]

A player who learns the best strategies through the q-learning algorithm.

This Q learner is quick to come to conclusions and doesn’t care about the future.

Names:

  • Risky Q Learner: Original strategy by Geraint Palmer
action_selection_parameter = 0.1
classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': {'game'}, 'inspects_source': False}
discount_rate = 0.9
find_reward(opponent)[source]

Finds the reward gained on the last iteration

find_state(opponent)[source]

Finds the my_state (the opponents last n moves + its previous proportion of playing C) as a hashable state

learning_rate = 0.9
memory_length = 12
name = 'Risky QLearner'
perform_q_learning(prev_state, state, action, reward)[source]

Performs the qlearning algorithm

receive_match_attributes()[source]
reset()[source]

Resets scores and history

select_action(state)[source]

Selects the action based on the epsilon-soft policy

strategy(opponent)[source]

Runs a qlearn algorithm while the tournament is running.

class axelrod.strategies.rand.Random(p: float=0.5) → None[source]

A player who randomly chooses between cooperating and defecting.

Names:

classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 0, 'makes_use_of': set(), 'inspects_source': False}
name = 'Random'
strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.retaliate.LimitedRetaliate(retaliation_threshold=0.1, retaliation_limit=20)[source]

A player that co-operates unless the opponent defects and wins. It will then retaliate by defecting. It stops when either, it has beaten the opponent 10 times more often that it has lost or it reaches the retaliation limit (20 defections).

Names:

  • LimitedRetaliate: Original strategy by Owen Campbell
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Limited Retaliate'
reset()[source]
strategy(opponent)[source]

If the opponent has played D to my C more often than x% of the time that I’ve done the same to him, retaliate by playing D but stop doing so once I’ve hit the retaliation limit.

class axelrod.strategies.retaliate.LimitedRetaliate2(retaliation_threshold=0.08, retaliation_limit=15)[source]

LimitedRetaliate player with a threshold of 8 percent and a retaliation limit of 15.

Names:

  • LimitedRetaliate2: Original strategy by Owen Campbell
name = 'Limited Retaliate 2'
class axelrod.strategies.retaliate.LimitedRetaliate3(retaliation_threshold=0.05, retaliation_limit=20)[source]

LimitedRetaliate player with a threshold of 5 percent and a retaliation limit of 20.

Names:

  • LimitedRetaliate3: Original strategy by Owen Campbell
name = 'Limited Retaliate 3'
class axelrod.strategies.retaliate.Retaliate(retaliation_threshold=0.1)[source]

A player starts by cooperating but will retaliate once the opponent has won more than 10 percent times the number of defections the player has.

Names:

  • Retaliate: Original strategy by Owen Campbell
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Retaliate'
reset()[source]
strategy(opponent)[source]

If the opponent has played D to my C more often than x% of the time that I’ve done the same to him, play D. Otherwise, play C.

class axelrod.strategies.retaliate.Retaliate2(retaliation_threshold=0.08)[source]

Retaliate player with a threshold of 8 percent.

Names:

  • Retaliate2: Original strategy by Owen Campbell
name = 'Retaliate 2'
class axelrod.strategies.retaliate.Retaliate3(retaliation_threshold=0.05)[source]

Retaliate player with a threshold of 5 percent.

Names:

  • Retaliate3: Original strategy by Owen Campbell
name = 'Retaliate 3'
class axelrod.strategies.sequence_player.SequencePlayer(generator_function, generator_args=())[source]

Abstract base class for players that use a generated sequence to determine their plays.

meta_strategy(value)[source]

Determines how to map the sequence value to cooperate or defect. By default, treat values like python truth values. Override in child classes for alternate behaviors.

reset()[source]
strategy(opponent)[source]
class axelrod.strategies.sequence_player.ThueMorse[source]

A player who cooperates or defects according to the Thue-Morse sequence. The first few terms of the Thue-Morse sequence are: 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 . . .

Thue-Morse sequence: http://mathworld.wolfram.com/Thue-MorseSequence.html

Names:

  • Thue Morse: Original by Geraint Palmer
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'ThueMorse'
class axelrod.strategies.sequence_player.ThueMorseInverse[source]

A player who plays the inverse of the Thue-Morse sequence.

Names:

  • Inverse Thue Morse: Original by Geraint Palmer
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
meta_strategy(value)[source]
name = 'ThueMorseInverse'
class axelrod.strategies.shortmem.ShortMem[source]

A player starts by always cooperating for the first 10 moves.

From the tenth round on, the player analyzes the last ten actions, and compare the number of defects and cooperates of the opponent, based in percentage. If cooperation occurs 30% more than defection, it will cooperate. If defection occurs 30% more than cooperation, the program will defect. Otherwise, the program follows the TitForTat algorithm.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 10, 'makes_use_of': set(), 'inspects_source': False}
name = 'ShortMem'
static strategy(opponent: axelrod.player.Player) → str[source]
class axelrod.strategies.titfortat.AdaptiveTitForTat(rate=0.5)[source]

ATFT - Adaptive Tit For Tat (Basic Model)

Algorithm

if (opponent played C in the last cycle) then world = world + r*(1-world) else world = world + r*(0-world) If (world >= 0.5) play C, else play D

Attributes

world : float [0.0, 1.0], set to 0.5
continuous variable representing the world’s image 1.0 - total cooperation 0.0 - total defection other values - something in between of the above updated every round, starting value shouldn’t matter as long as it’s >= 0.5

Parameters

rate : float [0.0, 1.0], default=0.5
adaptation rate - r in Algorithm above smaller value means more gradual and robust to perturbations behaviour

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Adaptive Tit For Tat'
reset()[source]
strategy(opponent)[source]
world = 0.5
class axelrod.strategies.titfortat.AntiTitForTat[source]

A strategy that plays the opposite of the opponents previous move. This is similar to Bully, except that the first move is cooperation.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Anti Tit For Tat'
static strategy(opponent)[source]
class axelrod.strategies.titfortat.Bully[source]

A player that behaves opposite to Tit For Tat, including first move.

Starts by defecting and then does the opposite of opponent’s previous move. This is the complete opposite of Tit For Tat, also called Bully in the literature.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Bully'
static strategy(opponent)[source]
class axelrod.strategies.titfortat.ContriteTitForTat[source]
name = 'Contrite Tit For Tat'
original_class

alias of ContriteTitForTat

strategy(opponent)
class axelrod.strategies.titfortat.Gradual[source]

A player that punishes defections with a growing number of defections but after punishing enters a calming state and cooperates no matter what the opponent does for two rounds.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Gradual'
reset()[source]
strategy(opponent)[source]
class axelrod.strategies.titfortat.HardTitFor2Tats[source]

A variant of Tit For Two Tats that uses a longer history for retaliation.

Names:

  • Hard Tit For Two Tats: Reference Required
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 3, 'makes_use_of': set(), 'inspects_source': False}
name = 'Hard Tit For 2 Tats'
static strategy(opponent)[source]
class axelrod.strategies.titfortat.HardTitForTat[source]

A variant of Tit For Tat that uses a longer history for retaliation.

Names:

  • Hard Tit For Tat: Reference Required
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 3, 'makes_use_of': set(), 'inspects_source': False}
name = 'Hard Tit For Tat'
static strategy(opponent)[source]
class axelrod.strategies.titfortat.OmegaTFT(deadlock_threshold=3, randomness_threshold=8)[source]

OmegaTFT modifies Tit For Tat in two ways: - checks for deadlock loops of alternating rounds of (C, D) and (D, C), and attempting to break them - uses a more sophisticated retaliation mechanism that is noise tolerant

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Omega TFT'
reset()[source]
strategy(opponent)[source]
class axelrod.strategies.titfortat.SlowTitForTwoTats[source]

A player plays C twice, then if the opponent plays the same move twice, plays that move.

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 2, 'makes_use_of': set(), 'inspects_source': False}
name = 'Slow Tit For Two Tats'
strategy(opponent)[source]
class axelrod.strategies.titfortat.SneakyTitForTat[source]

Tries defecting once and repents if punished.

Names:

  • Sneaky Tit For Tat: Reference Required
classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Sneaky Tit For Tat'
strategy(opponent)[source]
class axelrod.strategies.titfortat.SpitefulTitForTat[source]

A player starts by cooperating and then mimics the previous action of the opponent until opponent defects twice in a row, at which point player always defects

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Spiteful Tit For Tat'
reset()[source]
strategy(opponent)[source]
class axelrod.strategies.titfortat.SuspiciousTitForTat[source]

A variant of Tit For Tat that starts off with a defection.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Suspicious Tit For Tat'
static strategy(opponent)[source]
class axelrod.strategies.titfortat.TitFor2Tats[source]

A player starts by cooperating and then defects only after two defects by opponent.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 2, 'makes_use_of': set(), 'inspects_source': False}
name = 'Tit For 2 Tats'
static strategy(opponent)[source]
class axelrod.strategies.titfortat.TitForTat[source]

A player starts by cooperating and then mimics the previous action of the opponent.

Note that the code for this strategy is written in a fairly verbose way. This is done so that it can serve as an example strategy for those who might be new to Python.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 1, 'makes_use_of': set(), 'inspects_source': False}
name = 'Tit For Tat'
strategy(opponent)[source]

This is the actual strategy

class axelrod.strategies.titfortat.TwoTitsForTat[source]

A player starts by cooperating and replies to each defect by two defections.

Names:

classifier = {'manipulates_state': False, 'stochastic': False, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': 2, 'makes_use_of': set(), 'inspects_source': False}
name = 'Two Tits For Tat'
static strategy(opponent)[source]
class axelrod.strategies.worse_and_worse.KnowledgeableWorseAndWorse[source]

This strategy is based on ‘Worse And Worse’ but will defect with probability of ‘current turn / total no. of turns’.

Names:
  • Knowledgeable Worse and Worse: Original name by Adam Pohl
classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': {'length'}, 'inspects_source': False}
name = 'Knowledgeable Worse and Worse'
strategy(opponent)[source]
class axelrod.strategies.worse_and_worse.WorseAndWorse[source]

Defects with probability of ‘current turn / 1000’. Therefore it is more and more likely to defect as the round goes on.

Source code available at the download tab of [PRISON1998]

Names:
classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Worse and Worse'
strategy(opponent)[source]
class axelrod.strategies.worse_and_worse.WorseAndWorse2[source]

Plays as tit for tat during the first 20 moves. Then defects with probability (current turn - 20) / current turn. Therefore it is more and more likely to defect as the round goes on.

Names:
classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Worse and Worse 2'
strategy(opponent)[source]
class axelrod.strategies.worse_and_worse.WorseAndWorse3[source]

Cooperates in the first turn. Then defects with probability no. of opponent defects / (current turn - 1). Therefore it is more likely to defect when the opponent defects for a larger proportion of the turns.

Names:
classifier = {'manipulates_state': False, 'stochastic': True, 'long_run_time': False, 'manipulates_source': False, 'memory_depth': inf, 'makes_use_of': set(), 'inspects_source': False}
name = 'Worse and Worse 3'
strategy(opponent)[source]