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 import calculate_shanten

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

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

謝辞

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

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

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

Benchmark

https://zurukumo.github.io/kago-utils/dev/bench/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

kago_utils-0.1.4-cp314-cp314t-musllinux_1_2_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

kago_utils-0.1.4-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

kago_utils-0.1.4-cp314-cp314-musllinux_1_2_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

kago_utils-0.1.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

kago_utils-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

kago_utils-0.1.4-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

kago_utils-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

kago_utils-0.1.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

File details

Details for the file kago_utils-0.1.4-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for kago_utils-0.1.4-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e038740028a164c41a833c35f3e844fcf96475b00438d104140d9e92a61b1ad1
MD5 7b4f272333884cf05602d29e969e701d
BLAKE2b-256 f1f0821915627ee7e5964338ee1582cea9be343b4a0407efd4a455902546d1d2

See more details on using hashes here.

File details

Details for the file kago_utils-0.1.4-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for kago_utils-0.1.4-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 bf5420818e72bfdf0330230ee736a5e817fdd8a2c8712fa0a3e20e7ec5176802
MD5 e013f43f2d3466542d45ffb6fcc37bca
BLAKE2b-256 bedd1b41aa0c9764f358d5e6978810517bdd4281262ddd5fdcc146b73627d1d5

See more details on using hashes here.

File details

Details for the file kago_utils-0.1.4-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for kago_utils-0.1.4-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6d9d59c4b5828831ba82709f97b3270a6011c5dd7ca2cbff39f9b63b6cd6c382
MD5 3efdc3179a080a8202fa1ef681c17305
BLAKE2b-256 57ba6acefd05f789e53bb7bb6f224f94e2f2fa90527d272fc7ac31c657057eb4

See more details on using hashes here.

File details

Details for the file kago_utils-0.1.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for kago_utils-0.1.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e968d1354fe1b04be1df82b302217a8f98f1ad4de50326d91406982697fd0552
MD5 b2017331b02a9146ea7b69aa8b82ba52
BLAKE2b-256 31d9076917b2d4dccf02df7d4c1d6e69c0259b8f812a71566484dde8d746efd9

See more details on using hashes here.

File details

Details for the file kago_utils-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for kago_utils-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a86d99f254b1d4d24c4d9bc82215fec59c057ea0b629e716856513aab4c0c248
MD5 0e40a960d98138bfa44224d753af99d0
BLAKE2b-256 3aa92acae2b2d91f50f3a328379280306517a503312ddb1339e70e6d436e9b69

See more details on using hashes here.

File details

Details for the file kago_utils-0.1.4-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for kago_utils-0.1.4-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 bf6b754e46e48494ee23254a19cc98d982c248904dc0e017a622167b7a952979
MD5 2403fbab46cb501b061d764fb9caf6ee
BLAKE2b-256 e8c9d018fda5f93f5409abc910c63aa62e8362a39604dc1cb7bc28b47afe1a59

See more details on using hashes here.

File details

Details for the file kago_utils-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for kago_utils-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3de69decd0cb5c33d2ef8bdff743e52378aa7497f7cb0492f40e217944df5698
MD5 ea09020edb028dac1d951f5cdc5cb672
BLAKE2b-256 da2d4135cf30f910ef9c06d4dd502ecc53cd101f3c08b6c28813c4897ea4edcf

See more details on using hashes here.

File details

Details for the file kago_utils-0.1.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for kago_utils-0.1.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 79816718c6a28b9d95359af0007734eeeb7fe13f7b1fa758727f42a289cf65f0
MD5 31c0512a12cdadd6d03c0e0b935bda54
BLAKE2b-256 a723687c0682a0437c3363fca0a207348fdbce3c5b21c7765856ad03a5f14fee

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