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()