Japanese riichi mahjong hand calculator library.
Compute hand cost (han, fu, yaku, and scores), validate winning hands, and calculate shanten (minimum tiles to tenpai).
The code was validated on tenhou.net phoenix replays in total on 26,148,038 hands.
So, we can say that our hand calculator works the same way that tenhou.net hand calculation.
- API reference
- Wiki — Supported rules and usage examples
pip install mahjongTo set up the project locally for development:
Clone the repository:
git clone https://github.com/MahjongRepository/mahjong.git cd mahjongSetup env using uv:
uv sync
Run tests to verify setup:
make tests # Or directly: uv run pytestRun full checks before committing:
make check # Runs format, lint, and tests
This library is licensed under the MIT license.