Skip to content

Commit 88ec7b2

Browse files
zewaywongdrvinceknight
authored andcommitted
Added match class argument
1 parent 4ab64ab commit 88ec7b2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

axelrod/moran.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(
2929
mutation_method="transition",
3030
stop_on_fixation=True,
3131
seed=None,
32+
match_class=Match,
3233
) -> None:
3334
"""
3435
An agent based Moran process class. In each round, each player plays a
@@ -106,6 +107,7 @@ def __init__(
106107
else:
107108
self.deterministic_cache = DeterministicCache()
108109
self.turns = turns
110+
self.match_class = match_class
109111
self.prob_end = prob_end
110112
self.game = game
111113
self.noise = noise
@@ -376,7 +378,7 @@ def score_all(self) -> List:
376378
for i, j in self._matchup_indices():
377379
player1 = self.players[i]
378380
player2 = self.players[j]
379-
match = Match(
381+
match = self.match_class(
380382
(player1, player2),
381383
turns=self.turns,
382384
prob_end=self.prob_end,
@@ -574,3 +576,4 @@ def _get_scores_from_cache(self, player_names: Tuple) -> Tuple:
574576
except KeyError: # If players are stored in opposite order
575577
match_scores = self.cached_outcomes[player_names[::-1]].sample()
576578
return match_scores[::-1]
579+

axelrod/tournament.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(
3434
edges: List[Tuple] = None,
3535
match_attributes: dict = None,
3636
seed: int = None,
37+
match_class = Match,
3738
) -> None:
3839
"""
3940
Parameters
@@ -78,6 +79,7 @@ def __init__(
7879
turns = DEFAULT_TURNS
7980

8081
self.turns = turns
82+
self.match_class = match_class
8183
self.prob_end = prob_end
8284
self.match_generator = MatchGenerator(
8385
players=players,
@@ -451,7 +453,7 @@ def _play_matches(self, chunk, build_results=True):
451453
player2 = self.players[p2_index].clone()
452454
match_params["players"] = (player1, player2)
453455
match_params["seed"] = seed
454-
match = Match(**match_params)
456+
match = self.match_class(**match_params)
455457
for _ in range(repetitions):
456458
match.play()
457459

0 commit comments

Comments
 (0)