Spaces:
Running
Running
File size: 811 Bytes
17534de a099b2f 6a59296 a099b2f 17534de a099b2f 6a59296 a099b2f 17534de a099b2f 17534de |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
import random
choices = ["Rock", "Paper", "Scissors"]
def play_rps(user_choice):
bot_choice = random.choice(choices)
result = ""
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 f"You chose: {user_choice}\nBot chose: {bot_choice}\n\n{result}"
iface = gr.Interface(
fn=play_rps,
inputs=gr.Radio(choices, label="Choose your move"),
outputs="text",
title="Rock-Paper-Scissors Game",
description="Play against a bot. Make your move!"
)
iface.launch()
|