Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

antichess

antichess is a Python package for playing AntiChess, a chess variant where the goal is to have all of your pieces captured by your opponent. This package supports both two-player games and single-player games using strategic decision-making techniques such as Minimax with alpha-beta pruning, MCTS (Monte Carlo Tree Search), epsilon-greedy BFS (Breadth-First Search), and BFS.

Features

  • Two-Player Mode: Play against another human player.
  • Single-Player Mode: Play against an automated opponent using advanced strategic techniques.
  • Rules and Gameplay: Includes basic AntiChess rules and gameplay functionalities.
  • Board Display: Visual representation of the board and game state.

Installation

To use the AntiChessGame package, ensure you have Python 3.6 or higher installed. You can install the package directly if it is available on PyPI:

pip install antichess

Usage

Creating and Playing a New Two-Player Game

To create a new Two-Player AntiChess game:

from antichess.AntiChessGame import AntiChessGame

# Set showRules as `True` to print rules before the game begins
game = AntiChessGame(singlePlayer=False, showRules=False)

game.play()

Creating and Playing a New Single-Player Game

To play a single-player game against an automated opponent using a specified strategy:

from antichess.AntiChessGame import AntiChessGame
from antichess.Piece import PieceColor

# Set showRules as `True` to print rules before the game begins
game = AntiChessGame(singlePlayer=True, showRules=False)

# If not specified, agentColor will default to black
game.playAgent(strategy="minimax-depth=5", agentColor=PieceColor.WHITE)

Currently Valid Strategies

  • Random ("random") selects a move at random.
  • BFS ("bfs-depth=2", "bfs-depth=3") uses a breadth-first search.
  • Epsilon-Greedy BFS ("bfs-depth=2-e=.1", "bfs-depth=3-e=.1") integrates an epsilon-greedy policy with the established BFS approach.
  • MCTS ("mcts-sims=1000-depth=10", "mcts-sims=1000-depth=15", "mcts-sims=1500-depth=10") performs a Monte Carlo Tree Search.
  • Minimax with Alpha-Beta Pruning ("minimax-depth=3", "minimax-depth=5") uses the minimax algorithm with alpha-beta pruning.

Game Rules

  1. All pieces move like they do in regular chess, except for castling and en passant, which are not allowed.
  2. Capturing the king does not end the game.
  3. The winner is the first player to have all of their pieces captured.
  4. If a piece can be captured during your turn, you must capture it.
  5. Moves must be entered in UCI chess notation.
  6. Typing 'moves' will print a list of valid moves for the current turn.
  7. Typing 'quit' will forfeit the game, with the opponent being the winner by default.

Board Display

The board is displayed with ranks and files labeled.

License

This package is licensed under the GNU General Public License v3.0 License. See the LICENSE file for more details.

Contact

For any questions or feedback, please contact divit.rawal+antichess@gmail.com

Download files

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

Source Distribution

antichess-0.1.1.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

antichess-0.1.1-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file antichess-0.1.1.tar.gz.

File metadata

  • Download URL: antichess-0.1.1.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for antichess-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f28540f6228bb8981602be989a920aeaf856d25c824fbcccdbf0432c8a038766
MD5 cd7bfe3b03b0136f244acd4bbea714f6
BLAKE2b-256 8622db33c16fe28944b1f7367f70a6bbe4db5eaa63b148bb532681e361e14b00

See more details on using hashes here.

File details

Details for the file antichess-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: antichess-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for antichess-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a74407bbeeb49386dab6a5536a2daa1fdf5f09c4bffae0012c898c5dee46d8a3
MD5 5e2ee6dcd93ec1056b048210498558fa
BLAKE2b-256 908c40d263e8e7a18153f1b37ef996aa46ed4c9780a380b7e1d489a4002cb299

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page