Skip to main content

What is it?

A simple library for simulating and solving polymatrix games, where players are nodes of a network and edges represent two-player games.

Right now polymatrix can handle any amount of players and connections between them, but only two possible strategies and two state variables for each player. If your use case is not supported, reach out via email or post an issue, I'll see what I can do.

Installation

pip install polymatrix

Usage

Making a quick game between randomly connected 7 players and simulating 5 random rounds:

game = polymatrix.QuickGame(7)
game.simulate(5)

Making a game between 5 players on a ring topology (each player connected to two others) and with a starting state of 100 units for all players. Then play some strategy profiles:

game = polymatrix.PolymatrixGame(start_populations_matrix =[[100,100]]*5, topology="ring")
game.play(strategy_profile = [0,1,1,1,0])
print(game.state)

Architecture

The the high-level functionality (such as payoff functions) are in the PolymatrixGame class in polymatrixgame.py module, which inherits from more general MultiplayerGame from multiplayergame.py. The fundamental data of the game is information about the players (player.py) and how they are connected (network.py). The game network is really a networkx graph but with some extra methods (such as random edge addition/removal which I used for genetic programming). This is a high-level overview of dependencies:

Polymatrix game software architecture

There are 3 types of attributes to define a game: global_attributes, for example: probability of an edge existing, edge weight distribution, global utility etc player_attributes (specific to a node) link_attributes (specific to an edge)

Literature

I highly recommend a 2016 paper by Cai, Candogan, Daskalakis and Papadimitriou about zero-sum polymatrix games: https://www.cs.mcgill.ca/~cai/pdf/zerosum.pdf

For general algorithmic game theory: https://www.cs.cmu.edu/~sandholm/cs15-892F13/algorithmic-game-theory.pdf

Metadata

Release files for polymatrix 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polymatrix 0.0.4
File Size Uploaded
polymatrix-0.0.4.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for polymatrix 0.0.4
File Interpreter ABI Platform
polymatrix-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / polymatrix-0.0.4.tar.gz

Download URL polymatrix-0.0.4.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
84f1f55f3a724b2d9aab449f2aa4ed29830e676c22107c95edd5b63017f8386a
BLAKE2b-256 checksum
How to use checksums
a50efe9fa0790cbd3564eb600ecb50a3efd8be3a53a6ad689e8956fe572f625c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

Release files / polymatrix-0.0.4-py3-none-any.whl

Download URL polymatrix-0.0.4-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82ef2aa7c690f5d97d5d0907c0a65012bf6bbb400345253adb05809ffb12f508
BLAKE2b-256 checksum
How to use checksums
5fef927b4e7f5bee703f6f3d56decfce7d312d1dd55b79b1e19542d6a08f4657
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.1

2 release files

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