Multi-Agent Reinforcement Learning Environment for the board game Gobblet using PettingZoo.
Project description
gobblet-rl
Multi-Agent Reinforcement Learning Environment for the Gobblet board game board game using PettingZoo.
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_v0
env = gobblet_v0.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
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 gobblet-rl-1.0.2.tar.gz
.
File metadata
- Download URL: gobblet-rl-1.0.2.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a58d9c6b1025f0903c286bed4e4a2df605f362a6bd7259a206b3264b29e6d89f |
|
MD5 | 97841f230f217089bc145ae02bc52926 |
|
BLAKE2b-256 | b5bb50a020a8c664ee9c523d7c6116300eb0f854ac9c5f96c341a8b0b1e944b3 |
File details
Details for the file gobblet_rl-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: gobblet_rl-1.0.2-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c88e654147be1ba9fc31ba987c3fdc548bb4ff8f41466e73039dd63d01910a0 |
|
MD5 | 13993247e98c048ce7242b3ac0761955 |
|
BLAKE2b-256 | 9b7e53d00d88e3593b4ee6907e9c24ed19d4bd86c51a024e2f7ae5d8a30d8325 |