How to use the axelrod.Cooperator 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 / test_pickling.py View on Github external
def test_parameterized_player(self):
        p1 = axl.Cooperator()
        p2 = axl.Cycler('DDCCDD')

        p1.play(p2)

        reconstituted_1 = pickle.loads(pickle.dumps(p1))
        reconstituted_2 = pickle.loads(pickle.dumps(p2))

        self.assertEqual(p2, reconstituted_2)

        self.assertEqual(reconstituted_1.clone(), p1.clone())
        self.assertEqual(reconstituted_2.clone(), p2.clone())
github Axelrod-Python / axelrod-dojo / tests / unit / test_utils.py View on Github external
def test_deterministic_cooperator_never_fixes(self):
        player = axl.Cooperator()
        opponent = axl.Defector()
        expected_fixation_probabilities = [0 for _ in range(5)]
        fixation_probabilities = utils.objective_moran_win(player,
                                                           opponent,
                                                           turns=2,
                                                           repetitions=5,
                                                           noise=0)
        self.assertEqual(fixation_probabilities,
                         expected_fixation_probabilities)
github Axelrod-Python / Axelrod / axelrod / my_t.py View on Github external
pass

@st.NiceTransformer(name_prefix=None)
class Nice(axl.Cooperator):
    pass

@st.NoisyTransformer(0.2, name_prefix=None)
class Noisy(axl.Cooperator):
    pass

@st.RetaliationTransformer(3, name_prefix=None)
class Retaliation(axl.Cooperator):
    pass

@st.RetaliateUntilApologyTransformer(name_prefix=None)
class RetaliateUntilApology(axl.Cooperator):
    pass

@st.TrackHistoryTransformer(name_prefix=None)
class TrackHistory(axl.Cooperator):
    pass

transformed = [Apology, DeadlockBreaking, Flip, Final, Forgiver, Grudge,
               Initial, JossAnn, Mixed, Nice, Noisy, Retaliation,
               RetaliateUntilApology, TrackHistory]
fails = [Dual]
github Axelrod-Python / Axelrod / axelrod / my_t.py View on Github external
pass

@st.ForgiverTransformer(0.2, name_prefix=None)
class Forgiver(axl.Cooperator):
    pass

@st.GrudgeTransformer(3, name_prefix=None)
class Grudge(axl.Cooperator):
    pass

@st.InitialTransformer((C, D), name_prefix=None)
class Initial(axl.Cooperator):
    pass

@st.JossAnnTransformer((0.2, 0.2), name_prefix=None)
class JossAnn(axl.Cooperator):
    pass


strategies = [axl.Grudger, axl.TitForTat]
probability = [.2, .3]

@st.MixedTransformer(probability, strategies, name_prefix=None)
class Mixed(axl.Cooperator):
    pass

@st.NiceTransformer(name_prefix=None)
class Nice(axl.Cooperator):
    pass

@st.NoisyTransformer(0.2, name_prefix=None)
class Noisy(axl.Cooperator):
github Axelrod-Python / Axelrod / axelrod / my_t.py View on Github external
C, D = axl.Action.C, axl.Action.D


@st.FlipTransformer()
@st.FlipTransformer()
class TestFlip(axl.Cooperator):
    pass


@st.ApologyTransformer([D], [C])
class Apology(axl.Cooperator):
    pass


@st.DeadlockBreakingTransformer(name_prefix=None)
class DeadlockBreaking(axl.Cooperator):
    pass

@st.DualTransformer(name_prefix=None)
class Dual(axl.Cooperator):
    pass

@st.FlipTransformer(name_prefix=None)
class Flip(axl.Cooperator):
    pass

@st.FinalTransformer((D, D), name_prefix=None)
class Final(axl.Cooperator):
    pass

@st.ForgiverTransformer(0.2, name_prefix=None)
class Forgiver(axl.Cooperator):
github Axelrod-Python / Axelrod / axelrod / my_t.py View on Github external
probability = [.2, .3]

@st.MixedTransformer(probability, strategies, name_prefix=None)
class Mixed(axl.Cooperator):
    pass

@st.NiceTransformer(name_prefix=None)
class Nice(axl.Cooperator):
    pass

@st.NoisyTransformer(0.2, name_prefix=None)
class Noisy(axl.Cooperator):
    pass

@st.RetaliationTransformer(3, name_prefix=None)
class Retaliation(axl.Cooperator):
    pass

@st.RetaliateUntilApologyTransformer(name_prefix=None)
class RetaliateUntilApology(axl.Cooperator):
    pass

@st.TrackHistoryTransformer(name_prefix=None)
class TrackHistory(axl.Cooperator):
    pass

transformed = [Apology, DeadlockBreaking, Flip, Final, Forgiver, Grudge,
               Initial, JossAnn, Mixed, Nice, Noisy, Retaliation,
               RetaliateUntilApology, TrackHistory]
fails = [Dual]
github Axelrod-Python / Axelrod / axelrod / my_t.py View on Github external
import axelrod.strategy_transformers as st
import axelrod as axl

C, D = axl.Action.C, axl.Action.D


@st.FlipTransformer()
@st.FlipTransformer()
class TestFlip(axl.Cooperator):
    pass


@st.ApologyTransformer([D], [C])
class Apology(axl.Cooperator):
    pass


@st.DeadlockBreakingTransformer(name_prefix=None)
class DeadlockBreaking(axl.Cooperator):
    pass

@st.DualTransformer(name_prefix=None)
class Dual(axl.Cooperator):
    pass
github Axelrod-Python / Axelrod / axelrod / my_t.py View on Github external
import axelrod.strategy_transformers as st
import axelrod as axl

C, D = axl.Action.C, axl.Action.D


@st.FlipTransformer()
@st.FlipTransformer()
class TestFlip(axl.Cooperator):
    pass


@st.ApologyTransformer([D], [C])
class Apology(axl.Cooperator):
    pass


@st.DeadlockBreakingTransformer(name_prefix=None)
class DeadlockBreaking(axl.Cooperator):
    pass

@st.DualTransformer(name_prefix=None)
class Dual(axl.Cooperator):
    pass

@st.FlipTransformer(name_prefix=None)
class Flip(axl.Cooperator):
    pass

@st.FinalTransformer((D, D), name_prefix=None)
github Axelrod-Python / Axelrod / axelrod / my_t.py View on Github external
pass


strategies = [axl.Grudger, axl.TitForTat]
probability = [.2, .3]

@st.MixedTransformer(probability, strategies, name_prefix=None)
class Mixed(axl.Cooperator):
    pass

@st.NiceTransformer(name_prefix=None)
class Nice(axl.Cooperator):
    pass

@st.NoisyTransformer(0.2, name_prefix=None)
class Noisy(axl.Cooperator):
    pass

@st.RetaliationTransformer(3, name_prefix=None)
class Retaliation(axl.Cooperator):
    pass

@st.RetaliateUntilApologyTransformer(name_prefix=None)
class RetaliateUntilApology(axl.Cooperator):
    pass

@st.TrackHistoryTransformer(name_prefix=None)
class TrackHistory(axl.Cooperator):
    pass

transformed = [Apology, DeadlockBreaking, Flip, Final, Forgiver, Grudge,
               Initial, JossAnn, Mixed, Nice, Noisy, Retaliation,