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_list136とfrom_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.txttests/data/shanten/p_koku_10000.txttests/data/shanten/p_normal_10000.txttests/data/shanten/p_tin_10000.txt
は、あらの一人麻雀研究所 からお借りしました。
その他、一部のテストデータは天鳳の牌譜から作成しました。
Benchmark
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kago_utils-0.1.4-cp314-cp314t-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: kago_utils-0.1.4-cp314-cp314t-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.14t, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e038740028a164c41a833c35f3e844fcf96475b00438d104140d9e92a61b1ad1
|
|
| MD5 |
7b4f272333884cf05602d29e969e701d
|
|
| BLAKE2b-256 |
f1f0821915627ee7e5964338ee1582cea9be343b4a0407efd4a455902546d1d2
|
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
- Download URL: kago_utils-0.1.4-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.14t, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf5420818e72bfdf0330230ee736a5e817fdd8a2c8712fa0a3e20e7ec5176802
|
|
| MD5 |
e013f43f2d3466542d45ffb6fcc37bca
|
|
| BLAKE2b-256 |
bedd1b41aa0c9764f358d5e6978810517bdd4281262ddd5fdcc146b73627d1d5
|
File details
Details for the file kago_utils-0.1.4-cp314-cp314-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: kago_utils-0.1.4-cp314-cp314-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.14, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d9d59c4b5828831ba82709f97b3270a6011c5dd7ca2cbff39f9b63b6cd6c382
|
|
| MD5 |
3efdc3179a080a8202fa1ef681c17305
|
|
| BLAKE2b-256 |
57ba6acefd05f789e53bb7bb6f224f94e2f2fa90527d272fc7ac31c657057eb4
|
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
- Download URL: kago_utils-0.1.4-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.14, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e968d1354fe1b04be1df82b302217a8f98f1ad4de50326d91406982697fd0552
|
|
| MD5 |
b2017331b02a9146ea7b69aa8b82ba52
|
|
| BLAKE2b-256 |
31d9076917b2d4dccf02df7d4c1d6e69c0259b8f812a71566484dde8d746efd9
|
File details
Details for the file kago_utils-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: kago_utils-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a86d99f254b1d4d24c4d9bc82215fec59c057ea0b629e716856513aab4c0c248
|
|
| MD5 |
0e40a960d98138bfa44224d753af99d0
|
|
| BLAKE2b-256 |
3aa92acae2b2d91f50f3a328379280306517a503312ddb1339e70e6d436e9b69
|
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
- Download URL: kago_utils-0.1.4-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf6b754e46e48494ee23254a19cc98d982c248904dc0e017a622167b7a952979
|
|
| MD5 |
2403fbab46cb501b061d764fb9caf6ee
|
|
| BLAKE2b-256 |
e8c9d018fda5f93f5409abc910c63aa62e8362a39604dc1cb7bc28b47afe1a59
|
File details
Details for the file kago_utils-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: kago_utils-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3de69decd0cb5c33d2ef8bdff743e52378aa7497f7cb0492f40e217944df5698
|
|
| MD5 |
ea09020edb028dac1d951f5cdc5cb672
|
|
| BLAKE2b-256 |
da2d4135cf30f910ef9c06d4dd502ecc53cd101f3c08b6c28813c4897ea4edcf
|
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
- Download URL: kago_utils-0.1.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79816718c6a28b9d95359af0007734eeeb7fe13f7b1fa758727f42a289cf65f0
|
|
| MD5 |
31c0512a12cdadd6d03c0e0b935bda54
|
|
| BLAKE2b-256 |
a723687c0682a0437c3363fca0a207348fdbce3c5b21c7765856ad03a5f14fee
|