This is a collection of python libraries and scripts that manipulate empirical game data.
This package is hosted on pypi. Install it with pip install gameanalysis
.
The entry point from the command line is ga
. ga --help
will document all
available options.
The entry point for python is gameanalysis
. See the documentation for what is
available from the python interface.
After cloning this repository, the included Makefile
includes all the relevant actions to facilitate development.
Typing make
without targets will print out the various actions to help development.
Type make setup
to configure a virtual environment for development.
- Python 3 & venv
- BLAS/LAPACK
- A fortran compiler
All of the tests can be run with make test
.
If you want more fine grained control, you can run make test file=<file>
to execute tests for a single file in game analysis e.g. make test file=rsgame
.
Additionally, make coverage
and make coverage file=<file>
will run all of the tests and output a report on the coverage.
There are three game types: BaseGame, Game, and SampleGame.
BaseGame contains several functions that are valid for games without payoff data, and has the general structure that arbitrary game-like objects should inherit from.
Game is a potentially sparse mapping from role symmetric profiles to payoffs. It provides methods to quickly calculate mixture deviation gains, necessary for computing nash equilibria.
SampleGame retains payoff data for every observation. This allows it to resample the payoff data for every individual profile.
Internally this library uses arrays to store game profiles, and doesn't care about the names attached to a role or strategy, only their index. For consistence of lexicographic tie-breaking, roles and strategies are indexed in lexicographic order when serializing a named game into an internal array representation.
Generally follow PEP8 standard.
- Single quotes
- Lowercase underscore for method names
- Camelcase classes
- Unless obvious or necessary, try to only import modules not specific functions or classes from a module.
- Put a docstring for every public function and class. The first line should be short summary followed by a more detailed description perhaps detailing information about parameters or return values.
- flake8
Running make check
will search for some of these.
make format
will try to fix some in place.
- Change conditional in
dominance
, which indicates how to treat missing data to an enum or at least a string - Some functions in
dominance
could probably be more efficient. - Using array set operations would allow for convenient array operations like, "are all of these profiles present", however, it requires sorting of large void types which is very expensive, less so than just hashing the data. Maybe with pandas?
- Test requirements are also in requirements.txt because of issues loading them with xdist.
- Fix git dependencies, tie to a commit perhaps?
- add get_sample_payoffs to SampleGame?
- Consider making payoffs or profiles sparse? Currently this makes operations much slower and even for large sparse observation payoffs only save ~2 memory