Nashpy is a Python library providing algorithms for computing Nash equilibria and analyzing 2-player games, including matrix games and repeated games. It is built on top of NumPy and SciPy for efficient numerical computation. Currently at version 0.0.43, the library maintains a frequent release cadence, typically with minor updates and bug fixes.
pip install nashpyVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to define a 2-player, 2-strategy game using NumPy arrays for payoff matrices and find its Nash equilibria using the `support_enumeration` algorithm.
Convert lists to `numpy.array()` before passing them to the `Game` constructor, e.g., `A = np.array([[1, 2], [3, 4]])`.
Pin your `nashpy` version in `requirements.txt` or `pyproject.toml` to a specific patch version (e.g., `nashpy==0.0.43`) and review changelogs for updates before upgrading.
Consult the documentation for specific algorithm limitations. If issues arise, consider slightly perturbing game matrices (if appropriate for your problem domain) or exploring alternative algorithms provided by Nashpy.