Skip to main content

Multi-Agent Reinforcement Learning Environment for the board game Gobblet using PettingZoo.

Project description

gobblet-rl

PyPI version License

Multi-Agent Reinforcement Learning Environment for the Gobblet board game board game using PettingZoo.

Gobblet game

Installation

Using pip (recommended)

pip install gobblet-rl

Local

git clone hhttps://github.com/elliottower/gobblet-rl.git
cd gobblet-rl
pip install -e .

Usage

Setting up a basic environment

In a Python shell, run the following:

import pettingzoo
from gobblet import gobblet_v1

env = gobblet_v1.env()

Train a DQL agent with Tianshou

In the terminal, run the following:

python gobblet/example_tianshou.py

This will train a DQN model from Tianshou for 50 epochs, and then render the trained agent playing against a random agent in an example match.

Playing a game with a random agent

In the terminal, run the following:

python gobblet/example_random.py --render_mode="human" --agent_type="random"

Command-line arguments

--render_mode="human" will render a 3x3 board only showing the topmost pieces (pieces which are covered by others, or 'gobbled', are hidden):

TURN: 2, AGENT: player_1, ACTION: 51, POSITION: 6, PIECE: 3
       |       |       
  -    |   -   |   -3  
_______|_______|_______
       |       |       
  -    |   -   |   +2  
_______|_______|_______
       |       |       
  -    |   -   |   -   
       |       |       

--render_mode="human_full" will render three different 3x3 boards representing the small, medium and large pieces. This gives full information about pieces which are covered or 'gobbled' by other pieces. :

TURN: 3, AGENT: player_0, ACTION: 42, POSITION: 6, PIECE: 5
         SMALL                     MED                     LARGE           
       |       |                |       |                |       |       
  -    |   -   |   -       -    |   -   |   -       -    |   -   |   +5  
_______|_______|_______  _______|_______|_______  _______|_______|_______
       |       |                |       |                |       |       
  -    |   -   |   -2      -    |   -   |   -       -    |   -   |   -   
_______|_______|_______  _______|_______|_______  _______|_______|_______
       |       |                |       |                |       |       
  -    |   -   |   -       -    |   -   |   -       -    |   -   |   -6  
       |       |                |       |                |       |       

Testing

Testing can be done via pytest:

git clone https://github.com/elliottower/gobblet-rl.git
cd gobblet-rl
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gobblet-rl-1.1.0.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

gobblet_rl-1.1.0-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file gobblet-rl-1.1.0.tar.gz.

File metadata

  • Download URL: gobblet-rl-1.1.0.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for gobblet-rl-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e65495b7237d89e5ef72b2746b10a8589b47a0bcf7294d684cc9cad5f0e4ff66
MD5 c62761029a367dcd24ec9099f8734c7f
BLAKE2b-256 fd20efe991c71dd639e62fba2b1a20e3d94d8867ec335bb1fddd36c9b4e2d6d9

See more details on using hashes here.

File details

Details for the file gobblet_rl-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: gobblet_rl-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for gobblet_rl-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0bb82f7e89e19e1af6da389d7e6411dcc18cc2bf5861b5e17cc82917a953d5d0
MD5 40aa9411f1672848e53afdc54674db6f
BLAKE2b-256 9bfebd10a4482bdda6712535f8ba84029122687061cf356491cb5aaca328b490

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page