sergicalsix commited on
Commit
1839603
1 Parent(s): 2c4c211

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +2 -8
  2. flagged/log.csv +11 -0
  3. main.py +66 -0
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: Practice Mahjong App
3
- emoji: 🌍
4
- colorFrom: blue
5
- colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 4.16.0
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: practice_mahjong_app
3
+ app_file: main.py
 
 
4
  sdk: gradio
5
  sdk_version: 4.16.0
 
 
6
  ---
 
 
flagged/log.csv ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 役を選択,output,flag,username,timestamp
2
+ "['立直', '門前清自摸和']",,,,2024-01-27 00:28:45.285391
3
+ "['立直', '門前清自摸和']","選択された役: ['立直', '門前清自摸和']
4
+ 翻数(役満以上は全て13翻、七対子は1.5翻とした。): 2
5
+ 親の点数: 3900
6
+ 子の点数: 2000",,,2024-01-27 00:45:21.895830
7
+ ['国士無双'],"選択された役: ['国士無双']
8
+ 翻数: 13
9
+ (役満以上は全て13翻、七対子は1.5翻とした。)
10
+ 親の点数: 48000
11
+ 子の点数: 32000",,,2024-01-27 00:48:48.570956
main.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ yaku_list = [
4
+ "立直", "門前清自摸和", "一発", "ドラ",
5
+ "海底撈月", "河底撈魚", "嶺上開花", "槍槓",
6
+ "ダブル立直", "七対子", "混全帯幺九", "一気通貫",
7
+ "三色同順", "三色同刻", "三槓子", "対々和",
8
+ "三暗刻", "小三元", "混老頭", "二盃口",
9
+ "純全帯幺九", "混一色", "清一色", "国士無双",
10
+ "大三元", "四暗刻", "小四喜",
11
+ "大四喜", "字一色", "緑一色", "清老頭",
12
+ "九蓮宝燈", "四槓子", "天和",
13
+ "地和",
14
+ ]
15
+
16
+ yaku_hand = {
17
+ "立直":1, "門前清自摸和":1, "一発":1, "ドラ":1,
18
+ "海底撈月":1, "河底撈魚":1, "嶺上開花":1, "槍槓":1,
19
+ "ダブル立直":2, "七対子":1.5, "混全帯幺九":2, "一気通貫":2,
20
+ "三色同順":2, "三色同刻":2, "三槓子":2, "対々和":2,
21
+ "三暗刻":2, "小三元":2, "混老頭":2, "二盃口":3,
22
+ "純全帯幺九":3, "混一色":3, "清一色":6, "国士無双":13,
23
+ "大三元":13, "四暗刻":13, "小四喜":13,
24
+ "大四喜":13, "字一色":13, "緑一色":13, "清老頭":13,
25
+ "九蓮宝燈":13, "四槓子":13, "天和":13,
26
+ "地和":13,
27
+ }
28
+
29
+ parent_ron_points = {1:2000, 1.5:2400, 2:3900, 2.5:4800,3:7700, 3.5:9600,4:12000,5:12000,6:18000,7:18000,8:24000,9:24000,10:36000,11:36000,12:36000,13:48000}
30
+ children_ron_points = {1:1000, 2:2000, 3:3900, 4:8000,5:8000,6:12000,7:12000,8:16000,9:16000,10:24000,11:24000,12:24000,13:32000}
31
+
32
+ def calculate_score(selected_yaku):
33
+ hand = 0
34
+ for yaku in selected_yaku:
35
+ # 各役の翻数を加算
36
+ hand += yaku_hand[yaku]
37
+ if hand > 13:
38
+ hand = 13
39
+ # 少数点以下切り捨て
40
+ elif hand > 4:
41
+ hand = int(hand)
42
+
43
+ return hand, parent_ron_points[hand], children_ron_points[hand]
44
+
45
+
46
+
47
+ def mahjong_score_interface(selected_yaku):
48
+ hand, parent_ron_score, children_ron_score = calculate_score(selected_yaku)
49
+ return f"""
50
+ 選択された役: {selected_yaku}
51
+ 翻数: {hand}
52
+ 親(ロン): {parent_ron_score}
53
+ 子(ロン): {children_ron_score}
54
+ (役満以上は全て13翻、七対子は1.5翻とした。)
55
+ """
56
+
57
+ yaku_checkboxes = [gr.Checkbox(label=yaku) for yaku in yaku_list]
58
+
59
+ interface = gr.Interface(
60
+ fn=mahjong_score_interface,
61
+ inputs=[gr.components.CheckboxGroup(choices=yaku_list, label="役を選択")],
62
+ outputs="text",
63
+ title="簡易版麻雀点数計算アプリ"
64
+ )
65
+
66
+ interface.launch(share=True)