Registry / ai-ml / nashpy

nashpy

JSON →
library0.0.43pypypi✓ verified 21d ago

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 nashpy
INSTALL
IMPORT
SIG · NASHPY
N
nashpy
ai-mlpythonv0.0.43
Install
8.9s avg
Import
1926ms
Disk
248MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.43 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.932s · 246.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 8.9s · import 1.920s · 237MB
248MB installed
● package 248MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Game
from nashpy import Game
import nashpy as nash

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.

import nashpy as nash import numpy as np # Define payoff matrices for player 1 (A) and player 2 (B) A = np.array([[3, 0], [5, 1]]) B = np.array([[3, 5], [0, 1]]) # Create a Nash game object game = nash.Game(A, B) # Compute Nash equilibria using support enumeration equilibria = game.support_enumeration() # Print the equilibria (mixed strategies for each player) print("Nash Equilibria:") for eq in equilibria: print(eq)
Debug
Known issues
gotchaPayoff matrices for `nashpy.Game` must be `numpy.ndarray` objects. Passing plain Python lists directly will result in a `TypeError` or unexpected behavior.
fix
Convert lists to `numpy.array()` before passing them to the `Game` constructor, e.g., `A = np.array([[1, 2], [3, 4]])`.
affects: All versions
breakingAs a `0.0.x` version library, Nashpy's API is subject to change without strict adherence to semantic versioning. Minor version updates (e.g., 0.0.42 to 0.0.43) may introduce breaking changes.
fix
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.
affects: All 0.0.x versions
gotchaSome algorithms, particularly `lemke_howson` and `lemke_howson_lex`, may struggle or fail to converge on degenerate games or games with specific numerical properties. The library's focus is on general case solution.
fix
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.
affects: Versions 0.0.38+
Upgrade
Version history
0.0.43latest on PyPI · released Nov 6, 2025
Audit
Dependencies
numpyrequiredCore dependency for numerical operations and matrix representation.
scipyrequiredUsed for optimization routines and other scientific computing tasks.
matplotliboptionalRequired for plotting functionalities and examples.
Agent activity
7 hits · last 30 days
node
6
Resources
nashpy — pip install nashpy · libregistry