A library with algorithms on 2 player games.
Project description
Nashpy: a python library for 2 player games.
Nashpy is:
- An excellently documented library:
- The Nashpy game theory text book aims to be a course text on the background theory.
- The contributor documentation aims to be a text on research software development and help first time open source software contributions.
- A state of the art developed code base which aims to use the best of available tools to ensure the code is correct, readable and robust.
- Feature rich, the following are implemented:
- Support enumeration How to docs ๐ - Theory docs ๐
- Vertex enumeration How to docs ๐ - Theory docs ๐
- Lemke-Howson algorithm How to docs ๐ - Theory docs ๐
- Fictitious play How to docs ๐ - Theory docs ๐
- Stochastic fictitious play How to docs ๐ - Theory docs ๐
- Replicator dynamics How to docs ๐ - Theory docs ๐
- Replicator-mutation dynamics How to docs ๐ - Theory docs ๐
- Asymmetric replicator dynamics How to docs ๐ - Theory docs ๐
- Moran processes How to docs ๐
- Generate games from repeated games How to docs ๐ - Theory docs ๐
- Moran processes on interaction graphs How to docs ๐
- Moran processes on replication graphs How to docs ๐
Documentation
Full documentation is available here: http://nashpy.readthedocs.io/
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])
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/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nashpy-0.0.41.tar.gz
.
File metadata
- Download URL: nashpy-0.0.41.tar.gz
- Upload date:
- Size: 2.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ba0079d8a1a84d5afcd5e018d22cad72efa140928994a876c1ab9b8037c541a |
|
MD5 | 61b5a0de786f1e9089b9bab407a02ea4 |
|
BLAKE2b-256 | 3e92ff3b8b16e245d577b66b467f44e0f08e317a8b8cdf03bd613948109f37c1 |
File details
Details for the file nashpy-0.0.41-py3-none-any.whl
.
File metadata
- Download URL: nashpy-0.0.41-py3-none-any.whl
- Upload date:
- Size: 27.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0556c10682bad8ae92d24120352ea0656024c60d38fbb3669301d611eaea7828 |
|
MD5 | bbba9d5df0c5887357ccdaff4806a7d1 |
|
BLAKE2b-256 | 8174fa2cc83ed77b6018b48bc4da026d144c7a82aace7e44ccf318f436a559ed |