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_calculator import ShantenCalculator
# 手牌
tehai = HaiGroup.from_code("123m456p789s11122z")
# 向聴数
shanten = ShantenCalculator(tehai).shanten
print(shanten) # -1
謝辞
tests/data/p_hon_10000.txttests/data/p_koku_10000.txttests/data/p_normal_10000.txttests/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)
Built Distribution
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.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15534ca828da565f01151f24247d235bf8a633a687285c3dd736753f2556cba4
|
|
| MD5 |
45ea7d39cc48b7738aa67f1fc06a5050
|
|
| BLAKE2b-256 |
e659c6b99e7839dc77922ae81a5e989894e34b8bd574a808c586b773052a98b1
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70a9b21c60868b6bb6c21d05f1ba54532e27fa58b71a599930e53e0f9f1fd9bd
|
|
| MD5 |
de9d9df5dddc23c4c7299e8d644b9156
|
|
| BLAKE2b-256 |
9bdb38e0638dfcee959e0eb94c385cff8cc50fe4fd16670a8d5ac7fe4fb9851b
|