Skip to main content

DOI Discord Gitter 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 small set of Python dependencies: it only requires numpy and scipy so is straightforward to install on all operating systems.

Installation

$ python -m pip install nashpy

To install Nashpy on Fedora, use:

$ dnf install python3-nashpy

Usage

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])

Documentation

Full documentation is available here: http://nashpy.readthedocs.io/

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

Development

Clone the repository and create a virtual environment:

$ git clone https://github.com/drvinceknight/nashpy.git
$ 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

To build the documentation. First install the software which also installs the documentation build requirements.

$ python -m pip install flit
$ python -m flit install --symlink

Then:

$ cd docs
$ make html

Full contribution documentation is available at https://nashpy.readthedocs.io/en/latest/contributing/index.html

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: https://www.python.org/psf/codeofconduct/

Download files

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

Source Distribution

nashpy-0.0.31.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nashpy-0.0.31-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file nashpy-0.0.31.tar.gz.

File metadata

  • Download URL: nashpy-0.0.31.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for nashpy-0.0.31.tar.gz
Algorithm Hash digest
SHA256 0f4e35e9699afdbfc5f5f70705081220c9d6bb0ee28ca6ec009161e46215fe1d
MD5 2cdf54359682e43dcc1938ae59d1eaac
BLAKE2b-256 eac0ac45fb6db364999b1728ce8ea79ad7438d2c1093f4547d913d65b46ce661

See more details on using hashes here.

File details

Details for the file nashpy-0.0.31-py3-none-any.whl.

File metadata

  • Download URL: nashpy-0.0.31-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for nashpy-0.0.31-py3-none-any.whl
Algorithm Hash digest
SHA256 27211867e94d75bc168da87e28687cbdcc4f495df51b64da7b061f27113a16dc
MD5 ab6a113349a11023c31b15725a2bb2e5
BLAKE2b-256 4eb41e48fdff172ba5385f111126923f68a78779ec5dffc9ceafeb43b534d5c5

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.43

2 files

0.0.42

2 files

0.0.41

2 files

0.0.40

2 files

0.0.39

2 files

0.0.38

2 files

0.0.37

2 files

0.0.36

2 files

0.0.35

2 files

0.0.34

2 files

0.0.33

2 files

0.0.32

2 files

This release

0.0.31 This release

2 files

0.0.30

2 files

0.0.29

2 files

0.0.28

2 files

0.0.27

2 files

0.0.26

2 files

0.0.25

2 files

0.0.24

2 files

0.0.23

2 files

0.0.22

1 file

0.0.21

1 file

0.0.20

1 file

0.0.19

2 files

0.0.18

1 file

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

1 file

0.0.13

1 file

0.0.12

2 files

0.0.11

2 files

0.0.10

1 file

0.0.9

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page