How to use the axelrod.Match 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 assert_original_acts_same_as_pickled(self, player, turns=100):
        copy = pickle.loads(pickle.dumps(player))
        opponent_1 = axl.CyclerCCCDCD()
        opponent_2 = axl.CyclerCCCDCD()
        axl.seed(0)
        match_1 = axl.Match((player, opponent_1), turns=turns)
        result_1 = match_1.play()

        axl.seed(0)
        match_2 = axl.Match((copy, opponent_2), turns=turns)
        result_2 = match_2.play()

        self.assertEqual(result_1, result_2)
github Axelrod-Python / Axelrod / axelrod / test_pickling.py View on Github external
def test_final_transformer_called(self):
        player = axl.Alexei()
        copy = pickle.loads(pickle.dumps(player))
        match = axl.Match((player, copy), turns=3)
        results = match.play()
        self.assertEqual(results, [(C, C), (C, C), (D, D)])

        self.assert_original_acts_same_as_pickled(axl.Alexei(), turns=10)
github Axelrod-Python / Axelrod / axelrod / test_pickling.py View on Github external
def assert_original_acts_same_as_pickled(self, player, turns=100):
        copy = pickle.loads(pickle.dumps(player))
        opponent_1 = axl.CyclerCCCDCD()
        opponent_2 = axl.CyclerCCCDCD()
        axl.seed(0)
        match_1 = axl.Match((player, opponent_1), turns=turns)
        result_1 = match_1.play()

        axl.seed(0)
        match_2 = axl.Match((copy, opponent_2), turns=turns)
        result_2 = match_2.play()

        self.assertEqual(result_1, result_2)
github Axelrod-Python / axelrod-dojo / src / axelrod_dojo / utils.py View on Github external
def objective_score_diff(me, other, turns, noise, repetitions,
                         match_attributes=None):
    """Objective function to maximize total score difference over matches."""
    match = axl.Match((me, other), turns=turns, noise=noise,
                      match_attributes=match_attributes)
    if not match._stochastic:
        repetitions = 1
    scores_for_this_opponent = []

    for _ in range(repetitions):
        match.play()
        final_scores = match.final_score_per_turn()
        score_diff = final_scores[0] - final_scores[1]
        scores_for_this_opponent.append(score_diff)
    return scores_for_this_opponent
github Axelrod-Python / axelrod-dojo / src / axelrod_dojo / utils.py View on Github external
def objective_score(me, other, turns, noise, repetitions, match_attributes=None):
    """Objective function to maximize total score over matches."""
    match = axl.Match((me, other), turns=turns, noise=noise,
                      match_attributes=match_attributes)
    if not match._stochastic:
        repetitions = 1
    scores_for_this_opponent = []

    for _ in range(repetitions):
        match.play()
        scores_for_this_opponent.append(match.final_score_per_turn()[0])
    return scores_for_this_opponent
github Axelrod-Python / axelrod-dojo / src / axelrod_dojo / utils.py View on Github external
def objective_score(me, other, turns, noise, repetitions, match_attributes=None):
    """Objective function to maximize total score over matches."""
    match = axl.Match((me, other), turns=turns, noise=noise,
                      match_attributes=match_attributes)
    if not match._stochastic:
        repetitions = 1
    scores_for_this_opponent = []

    for _ in range(repetitions):
        match.play()
        scores_for_this_opponent.append(match.final_score_per_turn()[0])
    return scores_for_this_opponent