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

Release files for antichess 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for antichess 0.1.2
File Size Uploaded
antichess-0.1.2.tar.gz 22.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for antichess 0.1.2
File Interpreter ABI Platform
antichess-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 45.6 kB

Release files / antichess-0.1.2.tar.gz

Download URL antichess-0.1.2.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d7ec3e527ab5bde8be81d8b7f75c90e50404c1ef5dab05de9e68d23008bebb53
BLAKE2b-256 checksum
How to use checksums
782eae136b39725780bc7deb309b0b5637878d07cdbb7d44df3c853c46714429
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / antichess-0.1.2-py3-none-any.whl

Download URL antichess-0.1.2-py3-none-any.whl
Size 22.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe98d7275a74df3c61293466abb582962faaa68ff7eba0f008ae237fc4e0f538
BLAKE2b-256 checksum
How to use checksums
75c5441da546288ff612c6a358de8188deb4ca3e777f8a8fe8429a461289b548
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page