import streamlit as st import random # Define the choices choices = ['Rock', 'Paper', 'Scissors'] # Function to determine the winner def determine_winner(user_choice, ai_choice): if user_choice == ai_choice: return "It's a tie!" elif (user_choice == 'Rock' and ai_choice == 'Scissors') or \ (user_choice == 'Paper' and ai_choice == 'Rock') or \ (user_choice == 'Scissors' and ai_choice == 'Paper'): return 'You win!' else: return 'AI wins!' # Streamlit app layout st.title('Rock, Paper, Scissors Game') st.write('Choose your move:') # User selection user_choice = st.selectbox('Your choice:', choices) # AI selection if st.button('Play'): ai_choice = random.choice(choices) st.write(f'AI chose: {ai_choice}') result = determine_winner(user_choice, ai_choice) st.write(result)