A 4x4 Chess library (King + Rook vs King) with move validation and win/draw detection
Project description
Here’s your updated documentation in Markdown, including the intro you provided at the top:
# Chess4x4
A **4x4 Chess Library** written in Python.
Currently supports the classic endgame scenario **White King + Rook vs Black King** on a 4x4 chessboard.
---
## ✨ Features
- 4x4 chessboard
- Custom starting positions
- Supports **King** and **Rook**
- Generate all possible moves
- Make legal moves
- Detect **win** (capturing opponent King)
- Detect **draw** (only two Kings left)
- Turn-based play (White starts)
---
## 📦 Installation
```bash
pip install chess4x4
🚀 Quick Start
from chess4x4 import Chess4x4, King, Rook
# Initialize game
game = Chess4x4()
# Print the board
print(game.board)
# Generate moves for White King
moves = game.board.get_piece_moves((0, 0))
print("White King moves:", moves)
# Make a move
game.make_move((0, 0), (1, 0))
# Check status
print("Game over:", game.is_game_over())
📖 API Documentation
Classes
Chess4x4
make_move(start: tuple[int, int], end: tuple[int, int]) -> boolMake a move if legal. ReturnsTrueif successful.is_game_over() -> boolReturnsTrueif the game has ended.winner() -> str | NoneReturns"White","Black", orNone.
Board
get_piece_moves(position: tuple[int, int]) -> list[tuple[int, int]]Generate all legal moves for a piece.move_piece(start, end) -> boolMove a piece if valid.
Pieces
King(color: str, position: tuple[int, int])Rook(color: str, position: tuple[int, int])
🧪 Testing
Run tests with:
pytest tests/
🤝 Contributing
We welcome contributions!
-
Fork the repo
-
Create a new branch
git checkout -b feature-name
-
Commit your changes
git commit -m "Added feature X"
-
Push to your branch
git push origin feature-name
-
Create a Pull Request 🎉
Please make sure:
- Code is well-documented
- All tests pass
- Follow the existing coding style
📜 License
This project is licensed under the MIT License.
Do you want me to also create a **separate `CONTRIBUTING.md` file** with contribution guidelines, or keep it inside the main documentation only?
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chess4x4-0.1.3.tar.gz.
File metadata
- Download URL: chess4x4-0.1.3.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8aa8feb1827447ef158ea815cf11297d94a8b137455c9f42c407867158260bf
|
|
| MD5 |
ac67b501195746b9b7210bd4b41a2842
|
|
| BLAKE2b-256 |
fb71b5ac3028ae3ae60f5da25776ebe726dfdfe8e77ee8847e65c5f64def3e19
|
File details
Details for the file chess4x4-0.1.3-py3-none-any.whl.
File metadata
- Download URL: chess4x4-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42cbee3130648b719d5b9742848f547f4f716922115a726acbca3205393c8a50
|
|
| MD5 |
ccda1b123dded5b9b3058dcf049009fe
|
|
| BLAKE2b-256 |
593addb8e388b3820777290fc1b4436fdffa3b9b924a025d870fc9481572ebcb
|