Sanjayraju30 commited on
Commit
be4c921
ยท
verified ยท
1 Parent(s): a099b2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -1,11 +1,21 @@
1
  import gradio as gr
2
  import random
 
3
 
4
  choices = ["Rock", "Paper", "Scissors"]
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- def play_rps(user_choice):
7
  bot_choice = random.choice(choices)
8
- result = ""
9
 
10
  if user_choice == bot_choice:
11
  result = "It's a draw!"
@@ -18,15 +28,15 @@ def play_rps(user_choice):
18
  else:
19
  result = "You lose ๐Ÿ˜ข"
20
 
21
- return f"You chose: {user_choice}\nBot chose: {bot_choice}\n\n{result}"
 
22
 
23
  iface = gr.Interface(
24
- fn=play_rps,
25
  inputs=gr.Radio(choices, label="Choose your move"),
26
  outputs="text",
27
- title="Rock-Paper-Scissors Game",
28
- description="Play against a bot. Make your move!"
29
  )
30
 
31
  iface.launch()
32
-
 
1
  import gradio as gr
2
  import random
3
+ import time
4
 
5
  choices = ["Rock", "Paper", "Scissors"]
6
+ emoji_map = {"Rock": "โœŠ", "Paper": "โœ‹", "Scissors": "โœŒ๏ธ"}
7
+
8
+ def play_rps_animated(user_choice):
9
+ # Simulate countdown
10
+ countdown = "Rock... โœŠ\n"
11
+ time.sleep(0.5)
12
+ countdown += "Paper... โœ‹\n"
13
+ time.sleep(0.5)
14
+ countdown += "Scissors... โœŒ๏ธ\n"
15
+ time.sleep(0.5)
16
+ countdown += "Shoot!\n\n"
17
 
 
18
  bot_choice = random.choice(choices)
 
19
 
20
  if user_choice == bot_choice:
21
  result = "It's a draw!"
 
28
  else:
29
  result = "You lose ๐Ÿ˜ข"
30
 
31
+ return countdown + f"You chose: {user_choice} {emoji_map[user_choice]}\n" \
32
+ f"Bot chose: {bot_choice} {emoji_map[bot_choice]}\n\n" + result
33
 
34
  iface = gr.Interface(
35
+ fn=play_rps_animated,
36
  inputs=gr.Radio(choices, label="Choose your move"),
37
  outputs="text",
38
+ title="๐ŸŽฎ Rock-Paper-Scissors with Animation",
39
+ description="Play against a bot with animated countdown!"
40
  )
41
 
42
  iface.launch()