Skip to content

HP tests - #1007

Open
AndresFerCervell wants to merge 33 commits into
gambitproject:feature/hpfrom
AndresFerCervell:feature/hp_tests
Open

HP tests#1007
AndresFerCervell wants to merge 33 commits into
gambitproject:feature/hpfrom
AndresFerCervell:feature/hp_tests

Conversation

@AndresFerCervell

Copy link
Copy Markdown
Contributor

Description of the changes in this PR

This PR adds five new tests to our test suite.
The games tested have been selected from the catalog, using enumpoly_solve to choose the ones with a single Nash equilibrium.

The expected result is the equilibrium computed by the enumpoly solver.
The new games used are:

-books/myerson1991/fig2_1.efg
-books/vonstengel2022/fig10.1.efg
-journals/ijgt/nau2004/sec4.nfg
-journals/other/reiley2008/fig1.efg
-journals/ijgt/selten1975/fig2 which has a degenerate prior (player 1 can choose three strategies with payoff = 1 when t=0).
They all pass the test!

How to review this PR

Executing pytest and checking that the expected results are actually the NE of these games.

allcontributors Bot and others added 30 commits July 3, 2026 11:29
…ect#970)

* docs: update README.md

* docs: update .all-contributorsrc

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
)

Fixes a segfault in the AGG/BAGG file readers on malformed input.

Malformed input (e.g. an `.nfg` to `read_bagg`, or a degenerate `"0 0 0"` header) 
slipped past the header checks and dereferenced an empty vector in the AGG constructor, segfaulting. 
The parser code is unchanged from `master` and runs before any label normalization.

This validates header fields before construction; malformed headers now raise `ValueError`, valid files are unaffected.

Tests added: `test_read_agg_zero_header` / `test_read_bagg_zero_header` read `"0 0 0\n"` and expect `ValueError`. These segfault on unpatched code (taking down the `pytest` process, as in CI) rather than failing as an assertion.
* Added 3 player max cut test for enumpoly strategic form

* added strategic game tests for enumpoly strategic form: 3x3 coordination game, 3-player unique Nash (nau2004 sec4), 2x2x2 3 pure Nash (nau2004 sec5)
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…for players and strategies (gambitproject#965)

Make NormalizeGameLabels run unconditionally in every reader and remove
the normalize_labels / p_normalizeLabels parameter throughout the read
path: ReadEfgFile, ReadNfgFile, ReadGbtFile, ReadAggFile, ReadBaggFile,
ReadGame, and the pygambit read_* wrappers.
This fixes editing of GUI player labels to work more like expected:
* ESC cancels edits
* TAB also commits edits
* Losing focus commits edits
…t#985)

`build_support/catalog/update.py` was not building a fresh catalog from Git directly.   Instead, it was calling
`gbt.catalog.games(include_descriptions=True)`, so it was using whatever `pygambit` the Python environment is importing.  If that had an old installed/editable `pygambit`, or an old `build/lib.../pygambit/catalog_data`, it would “remember” deleted games.
This implements a variety of UX improvements for editing of labels in the GUI, especially taking into account our new rules about what constitutes a valid label, for which objects labels are required, and the requirements for labels being unique (within appropriate scope).

Closes gambitproject#945.
…ject#993)

This refactors and improves the control of long-running external processes.

* Clarifies the difference between the monitor dialog and the actual controller of the external process
* Makes the handling of the external process more robust
* Moves parsing of external process output into the process handler rather than the analysis output.

This is preparatory work which will enable the ability to run long-running processes as threads.
)

This implements a minimal, pseudo-XML parser targeted specifically
at the de-facto file format written as the "Gambit workspace" .gbt file format.

All reading and writing is consolidated with a data interface model
that does not depend on wxWidgets.

This allows the removal of tinyxml as a dependency being carried around
in the source.

Closes gambitproject#897.
This does some housekeeping in the LCP solvers:
* To be consistent with other methods, exceptions are not caught in the solver but
  allowed to propagate out.
* Instead of using exceptions to escape the `AllLemke` recursion, a return type is used.
…1000)

This standardises the structure of callbacks for Nash equilibrium methods:
* All methods call an "on equilibrium" callback, immediately upon identifying a profile as an equilibrium (to within given tolerances as appropriate)
* Methods for which progress updates are meaningful/useful define one or more event types, which are emitted (via a callback) when they occur.  These are method-specific.


Closes gambitproject#340 - as this now standardises to the extent sensible calling conventions across all methods.
…with a strategy (gambitproject#1003)

Co-authored-by: drdkad <d.a.kadnikov@gmail.com>
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 6 to 7.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@AndresFerCervell

AndresFerCervell commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

This PR has become a little chaotic since I wanted to use the new added games from the catalog which were not in feature/hp yet.
About the new commit:
Using 2x2x2.nfg as discussed, new tests have been added to test_hp.py that explore different priors. When choosing a prior that is exactly a pure equilibrium, or a small perturbation of it, the mentioned equilibrium is returned. If we select a prior that is a mixed equilibrium (actually a perturbation of it in order to avoid various best responses), also a pure equilibrium is returned.

Furthermore, now test_hp.py runs every game from the catalog that has a unique best response. The result´s max_regret is compared with 1e-8. They all pass in Linux and Windows, but books/vonstengel2022/fig10.12ends with 6.228842828764902e-05 = max_regret(). For now, I have removed it from the test suite, but we could discuss what to do with it.

As well as that, I have also tested every game with a unique best response (this has been computed by the algorithm since we have already checked that it works as expected) from contrib/games. I have added to the test suite only a brief selection of the ones I found most interesting so that the execution of pytest Is not eternal. I would be glad to add more in the future if is required. Here, the algorithm fails sometimes to reach a NE with the asked tolerance. To be exact, in the following games:
-todd1
-cent2
-wink3
-g2
-coord3
-todd2
-yamamoto
-3x3x3
The error always comes from the beginning, the tracer starts from t=0, but it selects the wrong direction and goes to negative numbers, often leading to an infinite loop. I have solved this issue by modifying hp.cc. In a few minutes a new PR will be available explaining the changes. After this modification, only wink3 does not get to reach an equilibrium. However, when changing c_maxDist = 0.4to 0.2, in path.cc, it does pass the test.

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.

5 participants