Skip to main content

A library to compute equilibria of 2 player normal form games

Project description

DOI Join the chat at DOI

Nashpy: a python library for the computation of equilibria of 2 player strategic games.

This library implements the following algorithms for Nash equilibria on 2 player games:

  • Support enumeration
  • Best response polytope vertex enumeration
  • Lemke Howson algorithm

Nashpy has a simple set of Python dependencies: it only requires numpy and scipy so is straightforward to install on all operating systems.


By design Nashpy is easy to install: the easiest way to install is from pypi:

$ python -m pip install nashpy

To install Nashpy on Fedora, use:

$ dnf install python3-nashpy


Create bi matrix games by passing two 2 dimensional arrays/lists:

>>> import nashpy as nash
>>> A = [[1, 2], [3, 0]]
>>> B = [[0, 2], [3, 1]]
>>> game = nash.Game(A, B)
>>> for eq in game.support_enumeration():
...     print(eq)
(array([1., 0.]), array([0., 1.]))
(array([0., 1.]), array([1., 0.]))
(array([0.5, 0.5]), array([0.5, 0.5]))
>>> game[[0, 1], [1, 0]]
array([3, 3])


Full documentation is available here:

Other game theoretic software

  • Gambit is a library with a python api and support for more algorithms and more than 2 player games.
  • Game theory explorer a web interface to gambit useful for teaching.
  • Axelrod a research library aimed at the study of the Iterated Prisoners dilemma


Clone the repository and create a virtual environment:

$ git clone
$ cd nashpy
$ python -m venv env

Activate the virtual environment and install tox:

$ source env/bin/activate
$ python -m pip install tox

Make modifications.

To run the tests:

$ python -m tox

Pull requests are welcome.

Code of conduct

In the interest of fostering an open and welcoming environment, all contributors, maintainers and users are expected to abide by the Python code of conduct:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for nashpy, version 0.0.23
Filename, size File type Python version Upload date Hashes
Filename, size nashpy-0.0.23-py3-none-any.whl (17.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size nashpy-0.0.23.tar.gz (222.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page