Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,18 @@
|
|
| 1 |
import random
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
return "
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
if player_position == 10:
|
| 19 |
-
return "You Win!"
|
| 20 |
-
|
| 21 |
-
# νμ¬ μμΉ νμ
|
| 22 |
-
game_map = [" "] * 10
|
| 23 |
-
game_map[player_position] = "P"
|
| 24 |
-
game_map[obstacle_position] = "O"
|
| 25 |
-
|
| 26 |
-
return " | ".join(game_map)
|
| 27 |
-
|
| 28 |
-
iface = gr.Interface(fn=run_game, inputs="text", outputs="text", title="Keyboard Controlled Game", description="Use 'Left' and 'Right' keys to move the player. Avoid obstacle 'O' and reach the box 'P'.")
|
| 29 |
iface.launch()
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 1 |
import random
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
def guess_number(user_input):
|
| 5 |
+
# μ»΄ν¨ν°κ° μ νν λλ€ μ«μ μμ±
|
| 6 |
+
computer_number = random.randint(1, 100)
|
| 7 |
+
|
| 8 |
+
# μ¬μ©μ μ
λ ₯κ³Ό μ»΄ν¨ν° μ«μ λΉκ΅
|
| 9 |
+
user_number = int(user_input)
|
| 10 |
+
if user_number == computer_number:
|
| 11 |
+
return f"μ λ΅μ
λλ€! μ»΄ν¨ν°κ° μ νν μ«μλ {computer_number}μ
λλ€."
|
| 12 |
+
elif user_number < computer_number:
|
| 13 |
+
return "λ ν° μ«μλ₯Ό μ
λ ₯νμΈμ."
|
| 14 |
+
else:
|
| 15 |
+
return "λ μμ μ«μλ₯Ό μ
λ ₯νμΈμ."
|
| 16 |
+
|
| 17 |
+
iface = gr.Interface(fn=guess_number, inputs="text", outputs="text", title="μ«μ λ§μΆκΈ° κ²μ", description="1μμ 100 μ¬μ΄μ μ«μλ₯Ό μ
λ ₯νμΈμ.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
iface.launch()
|
|
|
|
|
|
|
|
|