Skip to content

Fix death-birth MoranProcess pairing wrong players - #1502

Open
barlowa124 wants to merge 1 commit into
Axelrod-Python:devfrom
barlowa124:moran-db-matchup-indices-1499
Open

barlowa124 wants to merge 1 commit into
Axelrod-Python:devfrom
barlowa124:moran-db-matchup-indices-1499

Conversation

@barlowa124

Copy link
Copy Markdown

Fixes #1499.

In MoranProcess with mode="db", _matchup_indices() built matchups
from two different index spaces: enumerate(sources) produced positions
in the dead node's neighbour list, while self.index[target] produced
global player positions. score_all() then played and credited the wrong
players. Nothing raised, which kept it hidden.

Birth-death mode was unaffected only by accident: there sources covers
every vertex, so the enumerate counter coincides with self.index[source].

The change uses self.index[source] in both modes, so matchup pairs are
always global player positions. On the issue's reproduction (5-cycle,
player 2 dead) matchups go from {(0, 0), (1, 4)} to {(1, 0), (3, 4)}:
the dead node's neighbours (players 1 and 3) each play their own
out-neighbours, and the dead vertex is skipped.

A regression test pins the matchup set and the resulting scores in the
exact internal state __next__ creates before score_all().

pytest axelrod/tests/unit/test_moran.py passes: 44 tests.

In mode="db", _matchup_indices() used the enumerate position in the
dead node's neighbour list as the player index, so score_all() played
and credited the wrong players. Use self.index[source] so both modes
use global player positions. Fixes Axelrod-Python#1499.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MoranProcess death-birth mode pairs and scores the wrong players: _matchup_indices() mixes neighbour-list positions with global player indices

1 participant