Skip to main content

Mahjong Library for Python

Project description

kago-utils

Python用の麻雀ライブラリ。

Mahjong library for Python.

インストール

pip install kago-utils

使い方

牌姿の定義

from kago_utils.hai_group import HaiGroup

# from_codeの0は赤5を意味します。天鳳の牌理ツールと同じ仕様です。
tehai1 = HaiGroup.from_code("123m406p789s11122z")
tehai2 = HaiGroup.from_list34([0, 1, 2, 12, 13, 14, 24, 25, 26, 27, 27, 27, 28, 28])
tehai3 = HaiGroup.from_counter34([
    1, 1, 1, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 1, 1, 1, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 1, 1, 1,
    3, 2, 0, 0, 0, 0, 0
])

print(tehai1 == tehai2 == tehai3)  # True

from_list136from_counter136も同様に使えます。

向聴数の計算

from kago_utils.hai_group import HaiGroup
from kago_utils.shanten_calculator import ShantenCalculator

# 手牌
tehai = HaiGroup.from_code("123m456p789s11122z")

# 向聴数
shanten = ShantenCalculator(tehai).shanten
print(shanten)  # -1

謝辞

  • tests/data/p_hon_10000.txt
  • tests/data/p_koku_10000.txt
  • tests/data/p_normal_10000.txt
  • tests/data/p_tin_10000.txt

は、あらの一人麻雀研究所 からお借りしました。

その他、一部のテストデータは天鳳の牌譜から作成しました。

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

kago_utils-0.1.2.tar.gz (8.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kago_utils-0.1.2-py3-none-any.whl (8.0 MB view details)

Uploaded Python 3

File details

Details for the file kago_utils-0.1.2.tar.gz.

File metadata

  • Download URL: kago_utils-0.1.2.tar.gz
  • Upload date:
  • Size: 8.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kago_utils-0.1.2.tar.gz
Algorithm Hash digest
SHA256 15534ca828da565f01151f24247d235bf8a633a687285c3dd736753f2556cba4
MD5 45ea7d39cc48b7738aa67f1fc06a5050
BLAKE2b-256 e659c6b99e7839dc77922ae81a5e989894e34b8bd574a808c586b773052a98b1

See more details on using hashes here.

File details

Details for the file kago_utils-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: kago_utils-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kago_utils-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 70a9b21c60868b6bb6c21d05f1ba54532e27fa58b71a599930e53e0f9f1fd9bd
MD5 de9d9df5dddc23c4c7299e8d644b9156
BLAKE2b-256 9bdb38e0638dfcee959e0eb94c385cff8cc50fe4fd16670a8d5ac7fe4fb9851b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page