joseph7251 commited on
Commit
db88ac3
·
verified ·
1 Parent(s): cd65bb1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -10
app.py CHANGED
@@ -1,17 +1,26 @@
1
  import gradio as gr
2
- import pygame
3
 
4
- def start_game(difficulty):
5
- # 在這裡初始化 Pygame,根據 difficulty 設定遊戲難度
6
- pygame.init()
7
- # ... Pygame 遊戲邏輯 ...
8
 
9
- # Gradio 介面
 
 
 
 
 
 
 
 
 
10
  demo = gr.Interface(
11
- fn=start_game,
12
- inputs="number", # 輸入難度
13
- outputs="text", # 可以顯示遊戲狀態
14
- title="貪食蛇遊戲"
 
15
  )
16
 
 
17
  demo.launch()
 
1
  import gradio as gr
 
2
 
3
+ def draw_number(max_number):
4
+ """
5
+ 抽取一個隨機號碼
 
6
 
7
+ Args:
8
+ max_number: 班級座號的最大值
9
+
10
+ Returns:
11
+ 抽出的隨機號碼
12
+ """
13
+ import random
14
+ return random.randint(1, max_number)
15
+
16
+ # 建立使用者介面
17
  demo = gr.Interface(
18
+ fn=draw_number,
19
+ inputs="number",
20
+ outputs="text",
21
+ title="隨機抽號",
22
+ description="輸入班級座號的最大值,點擊抽籤"
23
  )
24
 
25
+ # 啟動伺服器
26
  demo.launch()