Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,17 +20,30 @@ st.title("Rock, Paper, Scissors")
|
|
| 20 |
|
| 21 |
st.write("Choose your move:")
|
| 22 |
|
| 23 |
-
# Create three buttons
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
computer_move = random.choice(moves)
|
| 35 |
|
| 36 |
# Display player and computer moves
|
|
|
|
| 20 |
|
| 21 |
st.write("Choose your move:")
|
| 22 |
|
| 23 |
+
# Create three horizontal buttons
|
| 24 |
+
col1, col2, col3 = st.columns(3)
|
| 25 |
+
|
| 26 |
+
with col1:
|
| 27 |
+
if st.button("Rock"):
|
| 28 |
+
player_move = "Rock"
|
| 29 |
+
with col2:
|
| 30 |
+
if st.button("Paper"):
|
| 31 |
+
player_move = "Paper"
|
| 32 |
+
with col3:
|
| 33 |
+
if st.button("Scissors"):
|
| 34 |
+
player_move = "Scissors"
|
| 35 |
+
|
| 36 |
+
# Ensure player_move is defined
|
| 37 |
+
if 'player_move' not in st.session_state:
|
| 38 |
+
st.session_state.player_move = None
|
| 39 |
+
|
| 40 |
+
# Assign player move to session state if a move is made
|
| 41 |
+
if 'player_move' in locals():
|
| 42 |
+
st.session_state.player_move = player_move
|
| 43 |
+
|
| 44 |
+
# If a move is selected, randomly choose a move for the computer and determine the result
|
| 45 |
+
if st.session_state.player_move:
|
| 46 |
+
player_move = st.session_state.player_move
|
| 47 |
computer_move = random.choice(moves)
|
| 48 |
|
| 49 |
# Display player and computer moves
|