A simple Weiqi (Go) library for Python
Project description
weiqi.py - Library for the game of Go
This is a library for the game of Go. It is written in Python and is designed to be easy to understand and use. It is also designed to be easy to extend and modify.
Usage
To use this library, you need to have Python installed on your computer.
To install the library, you can use the following command:
pip install weiqi
To use the library, you can import it in your Python code like this:
from weiqi import Board, WeiqiGame, Player, Stone
# Example user implementation
class User:
def __init__(self, name: str):
self.name = name
player_black = Player(User("Black"), Stone.BLACK)
player_white = Player(User("White"), Stone.WHITE)
# 19x19 board
board = Board.generate_empty_board(19)
game: WeiqiGame[User] = WeiqiGame(
players=[player_black, player_white],
board=board
)
# Then you can implement user interaction with the game
# through various interfaced (Example: CLI, GUI, etc.)
# You can also implement AI players
Testing
To run the tests, you can use the following command:
python -m unittest discover -s tests
Example
You can see an example with a simple Pygame GUI in the example/pygame_example.py file.
For starting the example, you can run the following command:
poetry install --only example
python example/pygame_example.py
After running the command, you should see a window pop up with a Go board. You can click on the board to place stones.
TODO
- Implement the end-game detection
- Implement the scoring system
- Implement the game history
- Implement the AI players
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
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 weiqi-0.1.0.tar.gz.
File metadata
- Download URL: weiqi-0.1.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.11.6-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fbbf44c27356449b5927ea5f48643de02b0a7530b31246df6e37fc2b16ad0c2
|
|
| MD5 |
1fd308575a4e9f88afa9e4fd880e3774
|
|
| BLAKE2b-256 |
e39113751fec728d9bd032fcebf8e968bd355eebd7747d487732637743f6d546
|
File details
Details for the file weiqi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: weiqi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.11.6-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce80f81f52dbeb3ef7dca8df1f8f0a868dbba7a94f0b2acd7d6f15016089e5d3
|
|
| MD5 |
068f033628dea406b18d8072fcdfd2bb
|
|
| BLAKE2b-256 |
3d1c700251dff9096bbe58b78ed8be3a0f5d7758e2cf8d1a6f49c35fbf2b3bd4
|