Package for simulating and playing antichess games.
Project description
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
- All pieces move like they do in regular chess, except for castling and en passant, which are not allowed.
- Capturing the king does not end the game.
- The winner is the first player to have all of their pieces captured.
- If a piece can be captured during your turn, you must capture it.
- Moves must be entered in UCI chess notation.
- Typing 'moves' will print a list of valid moves for the current turn.
- 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
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 antichess-0.1.2.tar.gz
.
File metadata
- Download URL: antichess-0.1.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 |
d7ec3e527ab5bde8be81d8b7f75c90e50404c1ef5dab05de9e68d23008bebb53
|
|
MD5 |
ae11df67d361b78cc8d220960508212c
|
|
BLAKE2b-256 |
782eae136b39725780bc7deb309b0b5637878d07cdbb7d44df3c853c46714429
|
File details
Details for the file antichess-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: antichess-0.1.2-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
fe98d7275a74df3c61293466abb582962faaa68ff7eba0f008ae237fc4e0f538
|
|
MD5 |
9129c4c981422e5ef1830fb808fa7090
|
|
BLAKE2b-256 |
75c5441da546288ff612c6a358de8188deb4ca3e777f8a8fe8429a461289b548
|