Skip to content

Commit d9ecf73

Browse files
committed
test wiki publishing
1 parent bf355f7 commit d9ecf73

File tree

5 files changed

+374
-0
lines changed

5 files changed

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

.github/wiki/English.md

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
Python 3.9+ is supported.
2+
3+
If you need Python 2 support, you can use the v1.1.11 version of the library.
4+
5+
The library contains various tools (shanten, agari, hand calculation)
6+
for the Japanese version of mahjong (riichi mahjong).
7+
8+
## Riichi mahjong hands calculation
9+
10+
It supports optional features like:
11+
12+
| Feature | Keyword parameter | Default value |
13+
|-------------------------------------------------------------------------------------------|---------------------------|-----------------------------|
14+
| Disable or enable open tanyao yaku | has_open_tanyao | False |
15+
| Disable or enable aka dora in the hand | has_aka_dora | False |
16+
| Disable or enable double yakuman (like suuanko tanki) | has_double_yakuman | True |
17+
| Settings for different kazoe yakuman calculation (it сan be an yakuman or a sanbaiman) | kazoe_limit | HandConstants.KAZOE_LIMITED |
18+
| Support kiriage mangan | kiriage | False |
19+
| Allow to disable additional +2 fu in open hand (you can make 1-20 hand with that setting) | fu_for_open_pinfu | True |
20+
| Disable or enable pinfu tsumo | fu_for_pinfu_tsumo | False |
21+
| Counting renhou as 5 han or yakuman | renhou_as_yakuman | False |
22+
| Disable or enable Daisharin yakuman | has_daisharin | False |
23+
| Disable or enable Daisharin in other suits (Daisuurin, Daichikurin) | has_daisharin_other_suits | False |
24+
| Disable or enable yakuman for dealing into open hands | has_sashikomi_yakuman | False |
25+
| Limit yakuman calculation to 6 (maximum score 192000) | limit_to_sextuple_yakuman | True |
26+
| Disable or enable extra yakuman for all honors 7 pairs | has_daichisei | False |
27+
| Disable or enable paarenchan without any yaku | paarenchan_needs_yaku | True |
28+
29+
The code was validated on tenhou.net phoenix replays in total on
30+
**11,120,125 hands**.
31+
32+
So, we can say that our hand calculator works the same way that
33+
tenhou.net hand calculation.
34+
35+
## How to use
36+
37+
You can find more examples here: https://github.com/MahjongRepository/mahjong/blob/v1.4.0/doc/examples.py
38+
39+
Let's calculate how much will cost this hand:
40+
41+
![image](https://user-images.githubusercontent.com/475367/30796350-3d30431a-a204-11e7-99e5-aab144c82f97.png)
42+
43+
### Tanyao hand by ron
44+
45+
```python
46+
from mahjong.hand_calculating.hand import HandCalculator
47+
from mahjong.tile import TilesConverter
48+
from mahjong.hand_calculating.hand_config import HandConfig
49+
from mahjong.meld import Meld
50+
51+
calculator = HandCalculator()
52+
53+
# we had to use all 14 tiles in that array
54+
tiles = TilesConverter.string_to_136_array(man='22444', pin='333567', sou='444')
55+
win_tile = TilesConverter.string_to_136_array(sou='4')[0]
56+
57+
result = calculator.estimate_hand_value(tiles, win_tile)
58+
59+
print(result.han, result.fu)
60+
print(result.cost['main'])
61+
print(result.yaku)
62+
for fu_item in result.fu_details:
63+
print(fu_item)
64+
```
65+
66+
Output:
67+
```
68+
1 40
69+
1300
70+
[Tanyao]
71+
{'fu': 30, 'reason': 'base'}
72+
{'fu': 4, 'reason': 'closed_pon'}
73+
{'fu': 4, 'reason': 'closed_pon'}
74+
{'fu': 2, 'reason': 'open_pon'}
75+
```
76+
77+
### How about tsumo?
78+
79+
```python
80+
result = calculator.estimate_hand_value(tiles, win_tile, config=HandConfig(is_tsumo=True))
81+
82+
print(result.han, result.fu)
83+
print(result.cost['main'], result.cost['additional'])
84+
print(result.yaku)
85+
for fu_item in result.fu_details:
86+
print(fu_item)
87+
```
88+
89+
Output:
90+
```
91+
4 40
92+
4000 2000
93+
[Menzen Tsumo, Tanyao, San Ankou]
94+
{'fu': 20, 'reason': 'base'}
95+
{'fu': 4, 'reason': 'closed_pon'}
96+
{'fu': 4, 'reason': 'closed_pon'}
97+
{'fu': 4, 'reason': 'closed_pon'}
98+
{'fu': 2, 'reason': 'tsumo'}
99+
```
100+
101+
### What if we add open set?
102+
103+
```python
104+
melds = [Meld(meld_type=Meld.PON, tiles=TilesConverter.string_to_136_array(man='444'))]
105+
106+
result = calculator.estimate_hand_value(tiles, win_tile, melds=melds, config=HandConfig(options=OptionalRules(has_open_tanyao=True)))
107+
108+
print(result.han, result.fu)
109+
print(result.cost['main'])
110+
print(result.yaku)
111+
for fu_item in result.fu_details:
112+
print(fu_item)
113+
```
114+
115+
Output:
116+
```
117+
1 30
118+
1000
119+
[Tanyao]
120+
{'fu': 20, 'reason': 'base'}
121+
{'fu': 4, 'reason': 'closed_pon'}
122+
{'fu': 2, 'reason': 'open_pon'}
123+
{'fu': 2, 'reason': 'open_pon'}
124+
```
125+
126+
Shanten calculation
127+
===================
128+
129+
```python
130+
from mahjong.shanten import Shanten
131+
132+
shanten = Shanten()
133+
tiles = TilesConverter.string_to_34_array(man='13569', pin='123459', sou='443')
134+
result = shanten.calculate_shanten(tiles)
135+
136+
print(result)
137+
```
138+
139+
Aotenjou scoring rules
140+
======================
141+
142+
```python
143+
tiles = TilesConverter.string_to_136_array(honors='111133555566667777')
144+
win_tile = TilesConverter.string_to_136_array(honors='3')[0]
145+
146+
melds = [
147+
Meld(meld_type=Meld.KAN, tiles=TilesConverter.string_to_136_array(honors='1111'), opened=False),
148+
Meld(meld_type=Meld.KAN, tiles=TilesConverter.string_to_136_array(honors='5555'), opened=False),
149+
Meld(meld_type=Meld.KAN, tiles=TilesConverter.string_to_136_array(honors='6666'), opened=False),
150+
Meld(meld_type=Meld.KAN, tiles=TilesConverter.string_to_136_array(honors='7777'), opened=False),
151+
]
152+
153+
result = calculator.estimate_hand_value(tiles, win_tile, melds=melds, dora_indicators=TilesConverter.string_to_136_array(honors='44447777'),
154+
scores_calculator_factory=Aotenjou, config=HandConfig(is_riichi=True, is_tsumo=True, is_ippatsu=True, is_haitei=True, player_wind=EAST, round_wind=EAST))
155+
156+
print(result.han, result.fu)
157+
print(result.cost['main'])
158+
print(result.yaku)
159+
for fu_item in result.fu_details:
160+
print(fu_item)
161+
```
162+
163+
Output:
164+
```
165+
103 160
166+
12980742146337069071326240823050300
167+
[Menzen Tsumo, Riichi, Ippatsu, Haitei Raoyue, Yakuhai (wind of place), Yakuhai (wind of round), Daisangen, Suu Kantsu, Tsuu Iisou, Suu Ankou Tanki, Dora 32]
168+
{'fu': 32, 'reason': 'closed_terminal_kan'}
169+
{'fu': 32, 'reason': 'closed_terminal_kan'}
170+
{'fu': 32, 'reason': 'closed_terminal_kan'}
171+
{'fu': 32, 'reason': 'closed_terminal_kan'}
172+
{'fu': 20, 'reason': 'base'}
173+
{'fu': 2, 'reason': 'pair_wait'}
174+
{'fu': 2, 'reason': 'tsumo'}
175+
```

.github/wiki/Home.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Documentation for the 1.4.0 version can be found here:
2+
- [[English]]
3+
- [[Chinese (简体中文)]]

.github/wiki/_Sidebar.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Table of Contents
2+
3+
- [[Home]]

.github/workflows/publish_wiki.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish Wiki
2+
3+
on:
4+
push:
5+
branches: [add-wiki]
6+
paths:
7+
- .github/wiki/**
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
publish:
14+
name: Publish Wiki
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 5
17+
18+
steps:
19+
- uses: actions/checkout@v6
20+
- uses: Andrew-Chen-Wang/github-wiki-action@v5
21+
with:
22+
path: .github/wiki/

0 commit comments

Comments
 (0)