MCPcopy Index your code
hub / github.com/MahjongRepository/mahjong

github.com/MahjongRepository/mahjong @v2.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.0 ↗ · + Follow
510 symbols 3,554 edges 105 files 228 documented · 45%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

mahjong

PyPI License Supported Python versions PyPI Downloads Linters and tests API Docs

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.

Documentation

How to install

pip install mahjong

Local development setup

To set up the project locally for development:

  1. Clone the repository:

    bash git clone https://github.com/MahjongRepository/mahjong.git cd mahjong

  2. Setup env using uv:

    bash uv sync

  3. Run tests to verify setup:

    ```bash make tests

    Or directly:

    uv run pytest ```

  4. Run full checks before committing:

    bash make check # Runs format, lint, and tests

License

This library is licensed under the MIT license.

Core symbols most depended-on inside this repo

string_to_136_array
called by 242
mahjong/tile.py
estimate_hand_value
called by 209
mahjong/hand_calculating/hand.py
string_to_34_array
called by 105
mahjong/tile.py
is_condition_met
called by 93
mahjong/hand_calculating/yaku.py
to_34_array
called by 30
mahjong/tile.py
calculate_fu
called by 28
mahjong/hand_calculating/fu.py
is_agari
called by 19
mahjong/agari.py
_is_mentsu
called by 18
mahjong/agari.py

Shape

Function 279
Method 143
Class 88

Languages

Python100%

Modules by API surface

tests/hand_calculating/tests_yaku_calculation.py51 symbols
tests/hand_calculating/tests_yakuman_calculation.py35 symbols
tests/hand_calculating/tests_hand_response_error.py25 symbols
tests/hand_calculating/tests_fu_calculation.py25 symbols
mahjong/utils.py25 symbols
tests/tests_utils.py24 symbols
mahjong/shanten.py24 symbols
tests/hand_calculating/tests_hand_dividing.py18 symbols
tests/hand_calculating/tests_aotenjou.py18 symbols
tests/tests_shanten.py14 symbols
tests/tests_agari.py14 symbols
mahjong/hand_calculating/divider.py14 symbols

For agents

$ claude mcp add mahjong \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact