An algorithm to reach a correlated equilibrium in multiplayer games.

Overview

build Documentation Status Downloads Codacy Badge codecov GitHub contributors Games

Correlatedpy: a python library for distributed learning of correlated equilibrium in multiplayer strategic games.

View Demo · Report Bug · Request Feature

The library implements a distributed learning algorithm allowing players to converge towards a correlated equilibrium point.

Installation

Correlatedpy has a small set of Python dependencies. It is straightforward to install on all operating systems as it only requires the following python packages

$ python -m pip install correlatedpy

To install Correlatepy on Fedora, use:

$ dnf install python3-correlatepy

The Environment

Parameters

The game has three global parameters that are shared accross all instances of all classes of the game. They can be initialized as follows

history = [(0,0)] # history of action profiles played by players
epsilon = 0.02 # exploration rate
alpha = 0.01 # targetted approximate correlated equilibrium

Players

the Player class has the attributes we list below:

  • number: object instance unique identifier
  • payoff: player's payoff matrix
  • state: player's state ('syn' or 'asyn')
  • history: game history
  • epsilon: exploration rate
  • alpha: approximate correlated alpha-equilibrium

We can now create the players by setting a value for each one of the parameters.

P1 = Player(number = 1, payoff = np.array([[0, 0], [1, -1]]), state = 'asyn', history = [(0, 0)], epsilon = 0.02, alpha = 0.01)
P2 = Player(number = 2, payoff = np.array([[0, 0], [-1, 1]]), state = 'asyn', history = [(0, 0)], epsilon = 0.02, alpha = 0.01)

Game

After creating players, we can now instanciate a game, define how many rounds to play, and add the players to it.

G = Game(iterations = 100000, history = [(0, 0)], epsilon = 0.02, alpha=0.01)

G.add_player(P1)
G.add_player(P2)

Learning

The game is played repeatedly by calling the instance method run().

G.run()

Simulation Results

G.results()

Diagram

Examples of Games

See the documentation for some examples and notebooks.

Chicken Game

This game has two pure Nash equilibria and one mixed Nash equilibrium.

  D C
D 0,0 7,2
C 2,7 6,6

We show the evolution of the probabilities of play of each profile.

Rock-Paper-Scissors

This game has a unique mixed Nash equilibrium point.

  R P S
R 0,0 -1,1 1,-1
P 1,-1 0,0 -1,1
S -1,1 1,-1 0,0

The simulation results show the probability of play of each profile.

A 3x2 game

This game has two mixed Nash equilibria.

  X Y
A 2,29 16,7
B 4,7 6,13
C 4,4 6,6

We show the empirical distribution of play of each profile.

three-player game

X Y
  C D
A 0,0,0 0,0,0
B 0,0,0 0,0,0
  C D
A 0,0,0 0,0,0
B 0,0,0 0,0,0

Usage

Payoff matrices

For an n-player game with action spaces of size , creating the payoff matrice for player i is performed in the following manner:

>>> import correlatedpy as correlated
>>> A = [[1, 2], [3, 0]]
>>> B = [[0, 2], [3, 1]]
>>> game = correlated.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://correlatedpy.readthedocs.io/

Citing

If you use the project in your work, please consider citing it with:

@misc{correlatedpy,
  author = {Boufous, Omar},
  title = {Correlatedpy: a python library for distributed learning of correlated equilibrium in multiplayer strategic games.},
  year = {2021},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/oboufous/correlatedpy}},
}

Other game theoretic software

  • Nashpy is a python library for the computation of equilibria of 2 player strategic games.
  • Gambit is a library with a python api and support for more algorithms and more than 2 player games.
  • Game theory explorer is a web interface to gambit useful for teaching.
  • Axelrod is 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/oboufous/correlatedpy.git
$ cd correlatedpy
$ 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://correlatedpy.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/

Owner
Omar Boufous
Research Scientist
Omar Boufous
SnailJumper - A game that is developed as an assignment for Computer Intelligence course

Snail jumper Neuroevolution game assignment. Fall 2021 - Computer Intelligence.

Soroush Mehraban 22 Aug 22, 2022
CoinTex: Cross-platform Multi-Level Game created in Python using Kivy

CoinTex: Cross-platform Multi-Level Game created in Python using Kivy CoinTex is a multi-level adventure game created using the Kivy cross-platform Py

Ahmed Gad 57 Dec 11, 2022
Wordle-Python - A simple low-key clone of the popular game WORDLE made with python and a 2D Graphics module Pygame

Wordle-Python A simple low-key clone of the popular game WORDLE made with python

Showmick Kar 7 Feb 10, 2022
A playable version of Chess – classic two-player, various AI levels, and the crazyhouse variant! Written in Python 3

A playable version of Chess – classic two-player, various AI levels, and the crazyhouse variant! Written in Python 3. Requires the installation of PIL/Pillow and Requests

1 Dec 24, 2021
A small game I made back in think 2011

Navi Network A small game I made back in think 2011. An online game inspired by the self-hosted nature of Minecraft, made with pygame, based on the Me

Peder Bergebakken Sundt 2 Jan 19, 2022
Automatic game data translator for RPGMaker-MV

RPGMaker-MV Translator 🕹️ 🎮 Use AI to translate all the dialogs and texts of your RPGMaker automatically. 👊 You worked hard to make your game, now

Davide Liu 11 Dec 26, 2022
Projeto Flappy Bird temática doom, projeto python e pygame

Doom-Bird Tecnologias usadas Requisitos para inicializar o jogo: Python faça o download em: https://www.python.org/downloads/ Após instalar o Python d

João Guilherme 1 Dec 08, 2021
BitBot - A simple shooter game

BitBot BitBot - A simple shooter game This project can be discontinued anytime I want, as it is not a "MAJOR" project for me. Which Game Engine does i

whmsft 1 Jan 04, 2022
Sukoku-solver Python About Sudoku is one of the most popular puzzle games of all time

Sukoku-solver Python About Sudoku is one of the most popular puzzle games of all time. As a logic puzzle, Sudoku is also an excellent brain game. Bein

Harshith VH 1 Nov 20, 2021
BUBBLE SHOOT - Pygame (python)

BUBBLE-SHOOT---Pygame BUBBLE SHOOT - Pygame (python) Bubbleshooter This is a Bubble shooter Game made with pygame. The arrow is controlled by the arro

ROBIN JONEY 1 Nov 12, 2021
Brawl Stars v31.96 server emulator written in Python.

Brawl Stars v31 Brawl Stars v31.96 server emulator written in Python. Requirements: Python 3.7 or higher pymongo dnspython colorama MongoDB configurat

9 Nov 26, 2021
Code and outputs from analysis determining that the wordle game can always be won in six moves.

wordle_worst_case_analysis Code and outputs from analysis determining that the wordle game can always be won in six moves. This is for the general cas

2 Aug 19, 2022
用于 blivechat 的图形界面

blivechat GUI 用于 blivechat 的图形界面。 有朋友在搞 Vtuber,像 blivechat 类似的项目能通过自定义 CSS 的方式在 OBS 上添加一个非常好看的聊天栏。但是想要在桌面端看到弹幕的话得要再开一个浏览器页面,十分不方便。就想写一个背景透明的浮窗浏览器。 挺喜欢

Silence 11 Dec 29, 2022
A python-based multi-player online educational game for students to play in a class or club setting.

Kurono (codename: aimmo) Code for Life has been developed by Ocado Technology as a free, open-source project to inspire the next generation of compute

Ocado Technology 108 Nov 07, 2022
A multiplayer RPG Discord bot, where you play as a god.

To run Ensure your Python is up to date, and install packages from requirements.txt Duplicate secrets-template.yaml, and name it secrets.yaml Insert y

4 Jan 18, 2022
Utility to find games owned by all (or at least some) of the passed players.

SteamCommonGameFinder Utility to find games that are owned by all (or at least some) of the players you pass into this programm. You can already find

Daniel O'Grady 4 Jan 04, 2022
An algorithm to reach a correlated equilibrium in multiplayer games.

Correlatedpy: a python library for distributed learning of correlated equilibrium in multiplayer strategic games. View Demo · Report Bug · Request Fea

Omar Boufous 2 Feb 01, 2022
A Higher-Lower web game made in Python using Flask framework.

Higher Lower Web Game Guess the random number from 0 to 9 in this web game made with Python and Flask Framework Modules that were used Random Flask In

Yago Goltara 1 Oct 27, 2021
Among AIs is a (prototype of) PC Game we developed as part of the Smart Applications course @ University of Pisa.

Among AIs is a PC Game we developed as part of the Smart Applications course @ Department of Computer Science of University of Pisa, under t

Gabriele Pisciotta 5 Dec 05, 2021
DOTD - A murder mystery game made in Python

DOTD This repo holds the files for my video game project from ENG101, Disaster o

Ben Bruzewski 1 Jan 13, 2022