GithubHelp home page GithubHelp logo

abhijeetkrishnan / fanorona-aec Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 644 KB

A PettingZoo AECEnv implementation of the board game Fanorona

Home Page: https://pypi.org/project/fanorona-aec/

License: MIT License

Python 100.00%
pettingzoo board-game-fanorona openai-gym-environment

fanorona-aec's Introduction

Fanorona AEC Environment

PyPI v3.0.2 License: MIT Ruff pre-commit

  A B C D E F G H I
5 ●─●─●─●─●─●─●─●─●
  │╲│╱│╲│╱│╲│╱│╲│╱│
4 ●─●─●─●─●─●─●─●─●
  │╱│╲│╱│╲│╱│╲│╱│╲│
3 ●─○─●─.─○─.─○─●─○
  │╲│╱│╲│╱│╲│╱│╲│╱│
2 ○─○─○─○─○─○─○─○─○
  │╱│╲│╱│╲│╱│╲│╱│╲│
1 ○─○─○─○─○─○─○─○─○

W to play
Last capture: E3 E
Visited: D3, E3
Half-moves: 0

This is an implementation of the Fanorona board game as a PettingZoo AEC game. The rules have been sourced from here. An additional rule where games exceeding $44$ moves end in a draw has been implemented, since the original rules do not have explicit draw conditions.

Installation

Using pip (recommended)

python -m pip install fanorona-aec

Local

git clone https://github.com/AbhijeetKrishnan/fanorona-aec.git
cd fanorona-aec
python -m pip install .

Usage

Setting up a basic environment

In a Python shell, run the following:

from fanorona_aec import fanorona_v3
env = fanorona_v3.env()

See demo.py for a script that implements a simple random policy to interact with the environment.

Testing

We use pytest for tests. You can run them via:

git clone https://github.com/AbhijeetKrishnan/fanorona-aec.git
cd fanorona-aec
python -m pip install .[dev]
pytest

fanorona-aec's People

Contributors

abhijeetkrishnan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fanorona-aec's Issues

Feature request: update PettingZoo version

Hi, would it be possible to update this repo to use the most recent version of PettingZoo? This project is listed in PettingZoo's third-party-environments, but we only want to include environments which work with the current version.

If you need any help working out issues due to different versions feel free to ask, there were some breaking changes in version 1.2, so it requires a bit of code changes to adapt. The previous API returned done in the step() function, whereas the new one returns truncated and terminated (matching gymnasium). There is a migration guide for gymnasium explaining the changes further, the steps should be basically the same (we're working on making resources for updating old PettingZoo repositories as well): https://gymnasium.farama.org/content/migration-guide/

Add more tests

Currently, there are fewer tests than are ideal. I would like to have more tests to inspire confidence in the package. These tests are based on checking the valid moves available from a game state, as well as checking that the resultant state from a move is correct.

Some examples are -

  • If no valid moves are present even with pieces on the board, declare a draw (probably not theoretically possible)
  • states in the middle of various capturing sequences

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.