|
import streamlit as st |
|
import random |
|
|
|
|
|
choices = ['Rock', 'Paper', 'Scissors'] |
|
|
|
|
|
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!' |
|
|
|
|
|
st.title('Rock, Paper, Scissors Game') |
|
st.write('Choose your move:') |
|
|
|
|
|
user_choice = st.selectbox('Your choice:', choices) |
|
|
|
|
|
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) |
|
|