立直麻将小工具
Project description
mahjong-utils-py
日麻小工具ssttkkl/mahjong-utils的Python绑定
已实现功能:
- 获取番符对应和牌点数
- 向听数、进张分析
- 和了分析(役种、番数、符数)
安装
pip install mahjong-utils
或通过源码安装(本机必须配置JDK环境用于编译):
pip install git+https://github.com/ssttkkl/mahjong-utils-py.git
使用
获取番符对应和牌点数
from mahjong_utils.point_by_han_hu import get_parent_point_by_han_hu, get_child_point_by_han_hu
# 获取亲家X番Y符的点数,返回(荣和点数, 自摸各家点数)
parent_ron, parent_tsumo = get_parent_point_by_han_hu(3, 40)
# parent_ron == 7700
# parent_tsumo == 2600
# 获取子家X番Y符的点数,返回(荣和点数, 自摸庄家点数, 自摸闲家点数)
child_ron, child_tsumo_parent, child_tsumo_child = get_child_point_by_han_hu(3, 40)
# child_ron == 5200
# child_tsumo_child == 1300
# child_tsumo_parent == 2600
向听数、进张分析
from mahjong_utils.models.tile import parse_tiles
from mahjong_utils.shanten import shanten
# 向听数、进张分析(未摸牌状态)
result = shanten(parse_tiles("34568m235p68s"))
result.shanten
# 1
result.advance
# {3m, 6m, 7m, 8m, 1p, 2p, 3p, 4p, 5p, 6s, 7s, 8s}
# 向听数、进张分析(已摸牌状态)
result = shanten(parse_tiles("112233p44556s127z"))
result.shanten
# 1
result.discard_to_advance
# {1p: ShantenWithoutGot(shanten=2, advance={2z, 7z, 1p, 4p, 3s, 6s, 1z}, advance_num=22, good_shape_advance=None, good_shape_advance_num=None),
# 2p: ShantenWithoutGot(shanten=2, advance={2z, 7z, 2p, 3s, 6s, 1z}, advance_num=18, good_shape_advance=None, good_shape_advance_num=None),
# 3p: ShantenWithoutGot(shanten=2, advance={2z, 7z, 3p, 3s, 6s, 1z}, advance_num=18, good_shape_advance=None, good_shape_advance_num=None),
# 4s: ShantenWithoutGot(shanten=2, advance={2z, 7z, 3s, 4s, 5s, 6s, 7s, 1z}, advance_num=24, good_shape_advance=None, good_shape_advance_num=None),
# 5s: ShantenWithoutGot(shanten=2, advance={2z, 7z, 2s, 3s, 4s, 5s, 6s, 1z}, advance_num=24, good_shape_advance=None, good_shape_advance_num=None),
# 6s: ShantenWithoutGot(shanten=1, advance={2z, 7z, 1z}, advance_num=9, good_shape_advance=set(), good_shape_advance_num=0),
# 1z: ShantenWithoutGot(shanten=1, advance={2z, 6s, 7z, 3s}, advance_num=13, good_shape_advance={2z, 7z}, good_shape_advance_num=6),
# 2z: ShantenWithoutGot(shanten=1, advance={6s, 3s, 7z, 1z}, advance_num=13, good_shape_advance={7z, 1z}, good_shape_advance_num=6),
# 7z: ShantenWithoutGot(shanten=1, advance={2z, 6s, 3s, 1z}, advance_num=13, good_shape_advance={2z, 1z}, good_shape_advance_num=6)}
和了分析
from mahjong_utils.hora import build_hora
from mahjong_utils.models.tile import parse_tiles, Tile
from mahjong_utils.models.wind import Wind
from mahjong_utils.models.furo import Furo
from mahjong_utils.yaku.common import self_wind, round_wind
# 和了分析
hora = build_hora(
tiles=parse_tiles("12233466m111z"),
furo=[Furo.parse("789p")],
agari=Tile.by_text("1z"),
tsumo=True,
dora=4,
self_wind=Wind.east,
round_wind=Wind.east
)
# hora.yaku == {self_wind, round_wind}
# hora.han == 6
# hora.hu == 30
# hora.parent_point == (18000, 6000)
# hora.child_point == (12000, 6000, 3000)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 mahjong-utils-0.2.0.tar.gz.
File metadata
- Download URL: mahjong-utils-0.2.0.tar.gz
- Upload date:
- Size: 162.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e7adb81a1ee2ae31f954654507a700a53a7619756ad38ecadc82f3d974a5266
|
|
| MD5 |
8ab0d3ee7512519c20ace91788adb09e
|
|
| BLAKE2b-256 |
8d8e0d955b43b94afeee87650559edde0413fe07934bd0285f69a538c56ddd7b
|
File details
Details for the file mahjong_utils-0.2.0-py3-none-win_amd64.whl.
File metadata
- Download URL: mahjong_utils-0.2.0-py3-none-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c7b8dd17e69c81bb5c5c40be747c7d4422ba011d6f2ba031e64d525d3fa6e30
|
|
| MD5 |
29f1ebe5a9a604c9f1fe3f9807855868
|
|
| BLAKE2b-256 |
76d0a29abfe9798699e0e29057a67b739f564ab84d410ebf0442abac745afe20
|
File details
Details for the file mahjong_utils-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: mahjong_utils-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 969.0 kB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3324a20038418de50b2c2116e691132fae62b4cce4a5ba87f3d3ffb5469ddabc
|
|
| MD5 |
6b9e3ed5d0d17176c14d118fa9212298
|
|
| BLAKE2b-256 |
0e43f34fa548f850de463362ace096696ceb845b196e47bfa8e377394e654ddb
|
File details
Details for the file mahjong_utils-0.2.0-py3-none-macosx_10_15_x86_64.whl.
File metadata
- Download URL: mahjong_utils-0.2.0-py3-none-macosx_10_15_x86_64.whl
- Upload date:
- Size: 843.9 kB
- Tags: Python 3, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
467d93a8df8854ee7a65a2fec0e5735a92c4ce5b4db029c52f5dd1d880f0104d
|
|
| MD5 |
55a0feb61fca289d5d6f878eac57e717
|
|
| BLAKE2b-256 |
b6bf640ae91d8efdc4a0b3923cbe5fab584f4e8f33e00be95cdf7b87c6a64c30
|