Skip to content

Commit 5e21198

Browse files
authored
chore: add wiki v2 pages (#179)
* remade structure * add v2 pages * mark as in development * test wiki * keep old page names * remove python 2 mentions * remove debug code * update wiki pages
1 parent 17fb4cc commit 5e21198

File tree

4 files changed

+477
-3
lines changed

4 files changed

+477
-3
lines changed

.github/wiki/Home.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
Documentation for the 1.4.0 version can be found here:
1+
# Mahjong Library Documentation
2+
3+
## v2 version (in development)
4+
- [[v2-English]]
5+
- [[v2-Chinese]]
6+
7+
## Previous Versions
8+
9+
### v1
210
- [[English]]
311
- [[Chinese (简体中文)]]

.github/wiki/_Sidebar.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1-
# Table of Contents
1+
# Documentation
22

3-
- [[Home]]
3+
**v2** (in development)
4+
- [[v2-English]]
5+
- [[v2-Chinese]]
6+
7+
**v1**
8+
- [[English]]
9+
- [[Chinese (简体中文)]]
10+
11+
---
12+
[[Home]]

.github/wiki/v2-Chinese.md

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
本软件包支持Python 3.10及以上版本。
2+
3+
本软件包包含日本麻雀(立直麻雀)各种相关计算工具(向听数计算、和牌判定、得点计算等)。
4+
5+
## 立直麻雀得点计算
6+
7+
本软件包可用于计算立直麻雀手牌详情(番数、符数、役种及得点)。
8+
9+
包含以下可选功能:
10+
11+
| 功能 | 关键字参数 | 默认值 |
12+
|------|-----------|--------|
13+
| 有无食断(非门前清断幺九是否成立) | `has_open_tanyao` | `False` |
14+
| 有无红宝牌 | `has_aka_dora` | `False` |
15+
| 有无双倍役满役种(如四暗刻单骑) | `has_double_yakuman` | `True` |
16+
| 非役满役种累计番数上限设置(累计役满/累计三倍满) | `kazoe_limit` | `HandConstants.KAZOE_LIMITED` |
17+
| 有无切上满贯 | `kiriage` | `False` |
18+
| 非门清平和型食和是否+2符(总计30符) | `fu_for_open_pinfu` | `True` |
19+
| 平和自摸是否仍然+2符(总计30符) | `fu_for_pinfu_tsumo` | `False` |
20+
| 人和是否视为役满(还是只有5番) | `renhou_as_yakuman` | `False` |
21+
| 是否有大车轮役种(门前清22334455667788饼) | `has_daisharin` | `False` |
22+
| 是否有其他花色的大车轮役种(索:大竹林,万:大数邻) | `has_daisharin_other_suits` | `False` |
23+
| 放铳开立直是否算役满 | `has_sashikomi_yakuman` | `False` |
24+
| 多倍役满是否上限为6倍(最高得点192000) | `limit_to_sextuple_yakuman` | `True` |
25+
| 是否有大七星役满役种(字牌七对子) | `has_daichisei` | `False` |
26+
| 八连庄是否需要有役才能成立 | `paarenchan_needs_yaku` | `True` |
27+
28+
本软件包经过tenhou.net(天凤)**11,120,125局**凤凰对局测试验证。
29+
30+
因此,我们可以确定所提供的算法与天凤算法一致。
31+
32+
## 如何使用
33+
34+
我们来计算一下下面这手牌的得点:
35+
36+
![image](https://user-images.githubusercontent.com/475367/30796350-3d30431a-a204-11e7-99e5-aab144c82f97.png)
37+
38+
### 断幺九荣和
39+
40+
```python
41+
from mahjong.hand_calculating.hand import HandCalculator
42+
from mahjong.tile import TilesConverter
43+
from mahjong.hand_calculating.hand_config import HandConfig
44+
from mahjong.meld import Meld
45+
46+
# we had to use all 14 tiles in that array
47+
tiles = TilesConverter.string_to_136_array(man='22444', pin='333567', sou='444')
48+
win_tile = TilesConverter.string_to_136_array(sou='4')[0]
49+
50+
result = HandCalculator.estimate_hand_value(tiles, win_tile)
51+
52+
print(result.han, result.fu)
53+
print(result.cost['main'])
54+
print(result.yaku)
55+
for fu_item in result.fu_details:
56+
print(fu_item)
57+
```
58+
59+
输出:
60+
61+
```
62+
1 40
63+
1300
64+
[Tanyao]
65+
{'fu': 30, 'reason': 'base'}
66+
{'fu': 4, 'reason': 'closed_pon'}
67+
{'fu': 4, 'reason': 'closed_pon'}
68+
{'fu': 2, 'reason': 'open_pon'}
69+
```
70+
71+
### 如果是自摸呢?
72+
73+
```python
74+
result = HandCalculator.estimate_hand_value(tiles, win_tile, config=HandConfig(is_tsumo=True))
75+
76+
print(result.han, result.fu)
77+
print(result.cost['main'], result.cost['additional'])
78+
print(result.yaku)
79+
for fu_item in result.fu_details:
80+
print(fu_item)
81+
```
82+
83+
输出:
84+
85+
```
86+
4 40
87+
4000 2000
88+
[Menzen Tsumo, Tanyao, San Ankou]
89+
{'fu': 20, 'reason': 'base'}
90+
{'fu': 4, 'reason': 'closed_pon'}
91+
{'fu': 4, 'reason': 'closed_pon'}
92+
{'fu': 4, 'reason': 'closed_pon'}
93+
{'fu': 2, 'reason': 'tsumo'}
94+
```
95+
96+
### 如果有副露又会如何?
97+
98+
```python
99+
from mahjong.hand_calculating.hand_config import OptionalRules
100+
101+
melds = [Meld(meld_type=Meld.PON, tiles=TilesConverter.string_to_136_array(man='444'))]
102+
103+
result = HandCalculator.estimate_hand_value(tiles, win_tile, melds=melds, config=HandConfig(options=OptionalRules(has_open_tanyao=True)))
104+
105+
print(result.han, result.fu)
106+
print(result.cost['main'])
107+
print(result.yaku)
108+
for fu_item in result.fu_details:
109+
print(fu_item)
110+
```
111+
112+
输出:
113+
114+
```
115+
1 30
116+
1000
117+
[Tanyao]
118+
{'fu': 20, 'reason': 'base'}
119+
{'fu': 4, 'reason': 'closed_pon'}
120+
{'fu': 2, 'reason': 'open_pon'}
121+
{'fu': 2, 'reason': 'open_pon'}
122+
```
123+
124+
### 立直与里宝牌
125+
126+
可以通过 `ura_dora_indicators` 参数传递里宝牌指示牌。里宝牌仅在立直和牌时计算。
127+
128+
```python
129+
tiles = TilesConverter.string_to_136_array(man='22444', pin='333567', sou='444')
130+
win_tile = TilesConverter.string_to_136_array(sou='4')[0]
131+
dora_indicators = TilesConverter.string_to_136_array(man='1')
132+
ura_dora_indicators = TilesConverter.string_to_136_array(pin='2')
133+
134+
result = HandCalculator.estimate_hand_value(
135+
tiles,
136+
win_tile,
137+
dora_indicators=dora_indicators,
138+
ura_dora_indicators=ura_dora_indicators,
139+
config=HandConfig(is_riichi=True, is_tsumo=True)
140+
)
141+
142+
print(result.han, result.fu)
143+
print(result.yaku)
144+
```
145+
146+
输出:
147+
148+
```
149+
10 40
150+
[Menzen Tsumo, Riichi, Tanyao, San Ankou, Dora 2, Ura Dora 3]
151+
```
152+
153+
## 向听数计算
154+
155+
```python
156+
from mahjong.shanten import Shanten
157+
from mahjong.tile import TilesConverter
158+
159+
tiles = TilesConverter.string_to_34_array(man='13569', pin='123459', sou='443')
160+
result = Shanten.calculate_shanten(tiles)
161+
162+
print(result)
163+
```
164+
165+
输出:
166+
167+
```
168+
2
169+
```
170+
171+
## 青天井规则
172+
173+
```python
174+
from mahjong.hand_calculating.hand import HandCalculator
175+
from mahjong.hand_calculating.hand_config import HandConfig
176+
from mahjong.hand_calculating.scores import Aotenjou
177+
from mahjong.tile import TilesConverter
178+
from mahjong.meld import Meld
179+
from mahjong.constants import EAST
180+
181+
tiles = TilesConverter.string_to_136_array(honors='111133555566667777')
182+
win_tile = TilesConverter.string_to_136_array(honors='3')[0]
183+
184+
melds = [
185+
Meld(meld_type=Meld.KAN, tiles=TilesConverter.string_to_136_array(honors='1111'), opened=False),
186+
Meld(meld_type=Meld.KAN, tiles=TilesConverter.string_to_136_array(honors='5555'), opened=False),
187+
Meld(meld_type=Meld.KAN, tiles=TilesConverter.string_to_136_array(honors='6666'), opened=False),
188+
Meld(meld_type=Meld.KAN, tiles=TilesConverter.string_to_136_array(honors='7777'), opened=False),
189+
]
190+
191+
result = HandCalculator.estimate_hand_value(
192+
tiles,
193+
win_tile,
194+
melds=melds,
195+
dora_indicators=TilesConverter.string_to_136_array(honors='4444'),
196+
ura_dora_indicators=TilesConverter.string_to_136_array(honors='7777'),
197+
scores_calculator_factory=Aotenjou,
198+
config=HandConfig(
199+
is_riichi=True,
200+
is_tsumo=True,
201+
is_ippatsu=True,
202+
is_haitei=True,
203+
player_wind=EAST,
204+
round_wind=EAST
205+
)
206+
)
207+
208+
print(result.han, result.fu)
209+
print(result.cost['main'])
210+
print(result.yaku)
211+
for fu_item in result.fu_details:
212+
print(fu_item)
213+
```
214+
215+
输出:
216+
217+
```
218+
103 160
219+
12980742146337069071326240823050300
220+
[Menzen Tsumo, Riichi, Ippatsu, Haitei Raoyue, Yakuhai (seat wind east), Yakuhai (round wind east), Daisangen, Suu Kantsu, Tsuu Iisou, Suu Ankou Tanki, Dora 16, Ura Dora 16]
221+
{'fu': 32, 'reason': 'closed_terminal_kan'}
222+
{'fu': 32, 'reason': 'closed_terminal_kan'}
223+
{'fu': 32, 'reason': 'closed_terminal_kan'}
224+
{'fu': 32, 'reason': 'closed_terminal_kan'}
225+
{'fu': 20, 'reason': 'base'}
226+
{'fu': 2, 'reason': 'pair_wait'}
227+
{'fu': 2, 'reason': 'tsumo'}
228+
```

0 commit comments

Comments
 (0)