# app.py import streamlit as st import random st.set_page_config(page_title="Rock Paper Scissors", page_icon="✊") st.title("Rock Paper Scissors Game") st.write("Play against the computer. First to 5 wins!") # Initialize session state if "user_score" not in st.session_state: st.session_state.user_score = 0 if "computer_score" not in st.session_state: st.session_state.computer_score = 0 if "round_result" not in st.session_state: st.session_state.round_result = "" choices = ["Rock", "Paper", "Scissors"] user_choice = st.radio("Choose your move:", choices) if st.button("Play Round"): computer_choice = random.choice(choices) st.write(f"Computer chose: **{computer_choice}**") if user_choice == computer_choice: st.session_state.round_result = "It's a tie!" elif ( (user_choice == "Rock" and computer_choice == "Scissors") or (user_choice == "Paper" and computer_choice == "Rock") or (user_choice == "Scissors" and computer_choice == "Paper") ): st.session_state.user_score += 1 st.session_state.round_result = "You win this round!" else: st.session_state.computer_score += 1 st.session_state.round_result = "Computer wins this round!" st.subheader(st.session_state.round_result) st.write(f"Your Score: {st.session_state.user_score}") st.write(f"Computer Score: {st.session_state.computer_score}") if st.session_state.user_score == 5: st.success("🎉 You won the game!") if st.session_state.computer_score == 5: st.error("💻 Computer won the game!") if st.button("Reset Game"): st.session_state.user_score = 0 st.session_state.computer_score = 0 st.session_state.round_result = "" # requirements.txt # Add this in a separate file when uploading to Hugging Face streamlit==1.31.0