How to use the axelrod.Actions.C function in Axelrod

To help you get started, we’ve selected a few Axelrod examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Axelrod-Python / Axelrod / axelrod / strategies / hunter.py View on Github external
from axelrod import Actions, Player
from axelrod._strategy_utils import detect_cycle

C, D = Actions.C, Actions.D


class DefectorHunter(Player):
    """A player who hunts for defectors."""

    name = 'Defector Hunter'
    classifier = {
        'memory_depth': float('inf'),  # Long memory
        'stochastic': False,
        'makes_use_of': set(),
        'long_run_time': False,
        'inspects_source': False,
        'manipulates_source': False,
        'manipulates_state': False
    }
github Axelrod-Python / Axelrod / axelrod / strategies / cycler.py View on Github external
def strategy(self, opponent):
        if self.cycle_counter < self.cycle_length:
            self.cycle_counter += 1
            return Actions.C
        else:
            self.cycle_length += 1
            self.cycle_counter = 0
            return Actions.D
github Axelrod-Python / Axelrod / axelrod / strategies / adaptive.py View on Github external
from axelrod import Actions, Player, init_args

C, D = Actions.C, Actions.D


class Adaptive(Player):
    """Start with a specific sequence of C and D, then play the strategy that
    has worked best, recalculated each turn.

    Names:

    - Adaptive: [Li2011]_

    """

    name = 'Adaptive'
    classifier = {
        'memory_depth': float('inf'),  # Long memory
        'stochastic': False,
github Axelrod-Python / Axelrod / axelrod / strategies / lookerup.py View on Github external
from functools import partial
from itertools import product
import sys

from axelrod import Actions, Player, init_args, load_lookerup_tables
from axelrod.strategy_transformers import InitialTransformer

module = sys.modules[__name__]
C, D = Actions.C, Actions.D

# Dictionary of table patterns
# Keys are (name, plays, op_plays, op_start_plays)
patterns = load_lookerup_tables()


def create_lookup_table_keys(plays, op_plays, op_start_plays):
    """Creates the keys for a lookup table."""
    self_histories = [''.join(x) for x in product('CD', repeat=plays)]
    other_histories = [''.join(x) for x in product('CD', repeat=op_plays)]
    opponent_starts = [''.join(x) for x in
                       product('CD', repeat=op_start_plays)]
    lookup_table_keys = list(product(opponent_starts, self_histories,
                                     other_histories))
    return lookup_table_keys
github Axelrod-Python / Axelrod / axelrod / cooperation.py View on Github external
from math import sqrt
from . import eigen
from axelrod import Actions
from axelrod.payoff import player_count

C, D = Actions.C, Actions.D


# As yet unused until RoundRobin returns interactions
def cooperation_matrix(interactions):
    """
    The cooperation matrix from a single round robin.

    Parameters
    ----------
    interactions : dictionary
        A dictionary of the form:

        e.g. for a round robin between Cooperator, Defector and Alternator
        with 2 turns per round:
        {
            (0, 0): [(C, C), (C, C)].