import random import streamlit as st # Define the choices choices = ["Rock", "Paper", "Scissors"] def determine_winner(user_choice, computer_choice): if user_choice == computer_choice: return "It's a tie!" elif ( (user_choice == "Rock" and computer_choice == "Scissors") or (user_choice == "Scissors" and computer_choice == "Paper") or (user_choice == "Paper" and computer_choice == "Rock") ): return "You win!" else: return "Computer wins!" # Streamlit UI st.title("Rock Paper Scissors Game") st.write("Choose your move and play against the computer!") # User input user_choice = st.radio("Your choice:", choices) # Play button if st.button("Play!"): computer_choice = random.choice(choices) # Display choices st.write(f"You chose: {user_choice}") st.write(f"Computer chose: {computer_choice}") # Determine winner result = determine_winner(user_choice, computer_choice) st.subheader(result) # Instructions for deployment st.sidebar.title("Instructions") st.sidebar.write( "This app can be deployed on [Hugging Face Spaces](https://huggingface.co/spaces) using the Streamlit SDK.\n" "1. Create a new space in your Hugging Face account.\n" "2. Set the SDK to `Streamlit`.\n" "3. Upload this script and the `requirements.txt` file.\n" "4. The app will be live after building." ) # Footer st.sidebar.write("Developed by [Engr. Junaid Qazi]")