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.
pip install mahjong
To set up the project locally for development:
Clone the repository:
bash
git clone https://github.com/MahjongRepository/mahjong.git
cd mahjong
Setup env using uv:
bash
uv sync
Run tests to verify setup:
```bash make tests
uv run pytest ```
Run full checks before committing:
bash
make check # Runs format, lint, and tests
This library is licensed under the MIT license.
$ claude mcp add mahjong \
-- python -m otcore.mcp_server <graph>