Game_point / app.py
Sanjayraju30's picture
Update app.py
be4c921 verified
raw
history blame
1.23 kB
import gradio as gr
import random
import time
choices = ["Rock", "Paper", "Scissors"]
emoji_map = {"Rock": "โœŠ", "Paper": "โœ‹", "Scissors": "โœŒ๏ธ"}
def play_rps_animated(user_choice):
# Simulate countdown
countdown = "Rock... โœŠ\n"
time.sleep(0.5)
countdown += "Paper... โœ‹\n"
time.sleep(0.5)
countdown += "Scissors... โœŒ๏ธ\n"
time.sleep(0.5)
countdown += "Shoot!\n\n"
bot_choice = random.choice(choices)
if user_choice == bot_choice:
result = "It's a draw!"
elif (
(user_choice == "Rock" and bot_choice == "Scissors") or
(user_choice == "Paper" and bot_choice == "Rock") or
(user_choice == "Scissors" and bot_choice == "Paper")
):
result = "You win! ๐ŸŽ‰"
else:
result = "You lose ๐Ÿ˜ข"
return countdown + f"You chose: {user_choice} {emoji_map[user_choice]}\n" \
f"Bot chose: {bot_choice} {emoji_map[bot_choice]}\n\n" + result
iface = gr.Interface(
fn=play_rps_animated,
inputs=gr.Radio(choices, label="Choose your move"),
outputs="text",
title="๐ŸŽฎ Rock-Paper-Scissors with Animation",
description="Play against a bot with animated countdown!"
)
iface.launch()