Python package scaffold for Othello/Reversi-related utilities.
Project description
othellopy
Python package scaffold for Othello/Reversi-related utilities.
Google Colab
Install the latest main branch in a Colab notebook:
!pip install git+https://github.com/Hietan/othellopy.git@main
Then import the package:
from othellopy.core import Piece
from othellopy.game import OthelloGame
from othellopy.player import BasePlayer
Player example
Use BasePlayer to build your own player class.
from othellopy.core import Piece
from othellopy.player import BasePlayer
class MyPlayer(BasePlayer):
def __init__(self, color: Piece) -> None:
super().__init__(color)
def next_move(self, board: list[list[Piece]]) -> tuple[int, int]:
return self.get_moves(board)[0]
Board cells use Piece.EMPTY, Piece.BLACK, and Piece.WHITE.
Coordinates are zero-based (row, col) pairs, matching board[row][col].
next_move() is called only when the player has at least one valid move.
Game example
Pass two player classes to OthelloGame and call play().
from othellopy.game import OthelloGame
result = OthelloGame(MyPlayer, MyPlayer).play()
print(result.winner)
print(result.black_score, result.white_score)
Use board helpers when debugging in notebooks.
from othellopy.board import print_board
print_board(result.board)
last_turn = result.turns[-1]
print(last_turn.valid_moves)
print_board(last_turn.board)
If a player returns an invalid move, the error message includes the move, valid moves, and the board for that turn.
Git Flow
Use these branch roles:
main: deployment branch for Colab installs.dev: integration branch before release.release/*: release preparation branch.feat/*: feature work branch.
Recommended flow:
git switch dev
git switch -c feat/my-feature
# work and commit
git switch dev
git merge --no-ff feat/my-feature
git switch -c release/v0.1.0
# final checks
git switch main
git merge --no-ff release/v0.1.0
git push origin main
Development
Create a virtual environment and install the package in editable mode:
uv venv
uv pip install -e ".[dev]"
Run tests:
uv run pytest
Build distributions:
uv build
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 othellopy-0.1.0.tar.gz.
File metadata
- Download URL: othellopy-0.1.0.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2d4192de67d4c8968f33d78ff4b0f58bb1481d6ca571da77d6fa435e9e3be36
|
|
| MD5 |
d3bd60f259c01c6965e824bbf5503d21
|
|
| BLAKE2b-256 |
d956f1846e9a52a921ea5fa204b17ba580cc1bdd4e08b53f80416a4c28b3b7a7
|
File details
Details for the file othellopy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: othellopy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92ce694ed4f3b4e62f661c90d7f7e0ef140f4bcc99a61f574a578ec99459ecf1
|
|
| MD5 |
e1690e79e44d6786ecbc30a452b42d6c
|
|
| BLAKE2b-256 |
1c39c50d903387cef33805a306220655ac77f2c2162f42ebeb3f9ae92be744e6
|