Skip to content

Fix death-birth MoranProcess pairing wrong players - #1502

Closed
barlowa124 wants to merge 62 commits into
Axelrod-Python:devfrom
barlowa124:moran-db-matchup-indices-1499
Closed

barlowa124 wants to merge 62 commits 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.

meatballs and others added 30 commits April 26, 2022 21:01
I've noticed that the "The Prisoner's Dilemma Competition" (http://www.prisoners-dilemma.com/competition.html) doesn't exist anymore on the website. I've added the archived version at the Wayback Machine.
…n_warnings

Fix string escape to suppress deprecation warning
I used cff init website to create a CITATION.cff file based on the author's information. There were some unclear given or family names. I made judgment calls, but please review them to ensure that they are correctly attributed. I included the readthedocs as a landing website and the GitHub's webpage as the location of the repository. Additional information about the authors (i.e., email, affiliation and ORCID) can optionally be added. I think the file's format is pretty clear but notify if that is not the case.
* Change workflow to test Python 3.11 instead of 3.8

* Update setup.py to use Python 3.11
…xelrod-Python#1407)

* Split requirements.txt to factor out hypothesis and prompt_toolkit

* Point config.yml to new requirements file

* Rewrite setup.py to use pathlib

* Correct documentation update

* Attempt to exclude condition import from coverage

* Change pragma no cover for human strategy inclusion

* Attempt to fix unused-import check for human strategy when prompt_toolkit is missing

* Format with black
run black on ubuntu only, change order of some tests
…#1413)

* Added asymmetric games and made regular games a subclass

* small improvements to code style

* fixing docs mock...

* Revert "fixing docs mock..."

This reverts commit 09fb251.

* used IntEnum to simplify

* small improvements & a fix

* added asymmetric games to docs

* added werror if invalid payoff matrices are given

* removed .item()

* changed dbs.action_to_int to use IntEnum behaviour

* Revert "changed dbs.action_to_int to use IntEnum behaviour"

This reverts commit bb6171c.

* made library code more robust wrt integer actions

* all strategies now work with integer actions

* added tests and fixed __eq__

* improved coverage

* changed Action back to Enum and added casting to score

* added casting test

* removed numpy mocking

* changed doc due to doctests being picky

* re-fixed doctest examples

* review changes

* Added tutorial for implementing new games

* fixed formatting

* made doctests work
* added a read the docs config file

* moved yaml to root directory
The tests were failing on ubuntu
https://github.com/Axelrod-Python/Axelrod/actions/runs/8198844499/job/22423011180?pr=1428

This was caused by some rounding error.

I think this cleans things up.
* Move to pyproject.toml.

This uses hatch.

Note I've removed the human player. I don't believe we ever use it. If
we want to we can add it back in.

* Bump version number.
* moved seed to tourney arg in hello world docs

* formatting

---------

Co-authored-by: Ian Miller <ianmiller@Ians-Mac.local>
* bump deps

* revert numpy to 1.26.4

* bump tox

* typo
gaffney2010 and others added 22 commits November 11, 2024 09:59
…rod-Python#1458)

* Improve extend method in LimitedHistory to enforce memory depth

- Updated the extend method in the LimitedHistory class to properly truncate oldest entries when the combined history exceeds the defined memory depth.

- Added a corresponding unit test in axelrod/tests/unit/test_history.py to validate this behavior.

- Formatted all committed files using black for consistent code style.

* Ignore workflow failures by adding suppress_health_check
- add suppress_health_check to test_equality function in test_game.py to prevent workflow failure in Github remote.
- Update HealthCheck module import order in test_game.py
* add freqAnalyzer strat

* cleanup + wip

* remove spurious changes

* fixed freq analyzer test

* Delete axelrod/tests/strategies/test_freqanalyzer.py

* bump num strats

* remove unnecessary lines

* fix type error

* fix test

* formatting

* python black with correct options

* add strat to index

* code cleanup
* add original index to summary

* formatting

* fix summary test

* rm spurious print statement

* fix failing doctest

* doctest attempt

* attempt

* cleanup

* formatting
* Get mypy working again

* Add test for new assert

* Test error string

* Inject get_data for testing

* More typing stuff for mypy to pass

* Ran black

* Added more mypy stuff to plot
… Prisoner's Dilemma (Axelrod-Python#1471)

* Adding attention strategy

* Adding deadline=None

* Adding verbosity to see which test is stalling the CI on ubuntu

* Use spawn instead of fork for new process

* Removing pytest-xdist -n auto

* Long run time

* Adding evolved attentio to long run strategies

* Adding min_value for s = 0

* Changing max_examples=5 to max_examples=2

* Adding test against strategies

* Removing stochastic strategy in test

* Fixing randomize test

* Lazy loading of model weights

* mypy compliance

* Shorter run time for test_meta

* Adding coverage to frequency analyzer
* Add link to discord server.

* Suppress too slow healthcheck.

* Fix ordering of imports.
* Fix numpy problem.

* Bump numpy version and modify outputs.

This makes all outputs be python floats. This somewhat fits with the
original (perhaps mistake) approach of the library where outputs are all
python objects (for example the results_set.payoff_matrix is a list of
lists although arguably should be a numpy array).

* Add support for py 3.13 + 3.14

* Bump numpy version.

* Format with black.

* Reorder tox so black runs first.
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.
@marcharper

Copy link
Copy Markdown
Member

The test is failing because the black formatter needs to be run.

@Evreu1pro

Copy link
Copy Markdown

Took this for a spin locally on top of 153335c: test_moran.py passes (44 passed) and the repro from #1499 now gives {(1, 0), (3, 4)} / [0.0, 5.0, 0, 0.0, 5.0], as expected. The black failure is just the players list in the new test. python -m black -l 80 axelrod/tests/unit/test_moran.py (the same -l 80 tox uses) splits it one player per line with a trailing comma, and moran.py itself is already clean. Not 100% sure the cancelled jobs are only fallout from that one failure, but that's the only thing black flags for me.

@drvinceknight

Copy link
Copy Markdown
Member

Thanks for this @barlowa124. The only thing stopping CI from passing is the formatting of the new test. Could you run:

python -m black -l 80 axelrod/tests/unit/test_moran.py

and push the result?

@barlowa124

Copy link
Copy Markdown
Author

Done in 73fb176. Ran python -m black -l 80 axelrod/tests/unit/test_moran.py and pushed. Watching CI.

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