Game_point / app.py
Sanjayraju30's picture
Update app.py
a099b2f verified
raw
history blame
811 Bytes
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()