Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def player(self):
return axl.Cooperator()
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())
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)
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]
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):
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):
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]
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
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)
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,