Skip to content

A library for the computation of Nash equilibria in two player games

License

Notifications You must be signed in to change notification settings

paulshuva/Nashpy

 
 

Repository files navigation

Coverage Status Build Status Build status DOI Join the chat at https://gitter.im/Nashpy/Lobby

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

This is a library with simple dependencies (it only requires numpy and scipy) so that it is pip installable: if you want to do sophisticated equilibria computation YOU SHOULD use gambit.

This is an implementation of the following algorithms for equilibria of 2 player games:

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

Installation

The easiest way to install is from pypi:

$ pip install nashpy

Usage

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

>>> import nash
>>> A = [[1, 2], [3, 0]]
>>> B = [[0, 2], [3, 1]]
>>> battle_of_the_sexes = nash.Game(A, B)
>>> for eq in battle_of_the_sexes.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]))
>>> battle_of_the_sexes[[0, 1], [1, 0]]
array([3, 3])

Documentation

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

Development

To install a development version of this library:

$ python setup.py develop

To run the full test suite:

$ python setup.py test

All contributions are welcome, although this is meant to be a simple library, for more detailed game theoretic contribution please see gambit.

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/

About

A library for the computation of Nash equilibria in two player games

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%