{"id":5337,"library":"nashpy","title":"Nashpy","description":"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.","status":"active","version":"0.0.43","language":"en","source_language":"en","source_url":"https://github.com/drvinceknight/Nashpy","tags":["game theory","mathematics","optimization","economics","simulation"],"install":[{"cmd":"pip install nashpy","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for numerical operations and matrix representation.","package":"numpy"},{"reason":"Used for optimization routines and other scientific computing tasks.","package":"scipy"},{"reason":"Required for plotting functionalities and examples.","package":"matplotlib","optional":true}],"imports":[{"symbol":"Game","correct":"import nashpy as nash\ngame = nash.Game(A, B)"},{"note":"Main algorithms like support_enumeration are often accessed directly or via the Game object.","symbol":"VertexEnum","correct":"from nashpy.algorithms import support_enumeration"}],"quickstart":{"code":"import nashpy as nash\nimport numpy as np\n\n# Define payoff matrices for player 1 (A) and player 2 (B)\nA = np.array([[3, 0], [5, 1]])\nB = np.array([[3, 5], [0, 1]])\n\n# Create a Nash game object\ngame = nash.Game(A, B)\n\n# Compute Nash equilibria using support enumeration\nequilibria = game.support_enumeration()\n\n# Print the equilibria (mixed strategies for each player)\nprint(\"Nash Equilibria:\")\nfor eq in equilibria:\n    print(eq)","lang":"python","description":"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."},"warnings":[{"fix":"Convert lists to `numpy.array()` before passing them to the `Game` constructor, e.g., `A = np.array([[1, 2], [3, 4]])`.","message":"Payoff matrices for `nashpy.Game` must be `numpy.ndarray` objects. Passing plain Python lists directly will result in a `TypeError` or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"As 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.","severity":"breaking","affected_versions":"All 0.0.x versions"},{"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.","message":"Some 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.","severity":"gotcha","affected_versions":"Versions 0.0.38+"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}