Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,10 +21,10 @@ def determine_winner(player_move, computer_move):
|
|
| 21 |
elif (player_move == "Rock" and computer_move == "Scissors") or \
|
| 22 |
(player_move == "Paper" and computer_move == "Rock") or \
|
| 23 |
(player_move == "Scissors" and computer_move == "Paper"):
|
| 24 |
-
playerWin+=1
|
| 25 |
return "You win!"
|
| 26 |
else:
|
| 27 |
-
computerWin+=1
|
| 28 |
return "You lose!"
|
| 29 |
|
| 30 |
# Streamlit app
|
|
@@ -46,6 +46,11 @@ with col3:
|
|
| 46 |
player_move = "Scissors"
|
| 47 |
|
| 48 |
# Ensure player_move is defined
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
if 'player_move' not in st.session_state:
|
| 50 |
st.session_state.player_move = None
|
| 51 |
|
|
@@ -88,10 +93,10 @@ if st.session_state.player_move:
|
|
| 88 |
|
| 89 |
if count == 3:
|
| 90 |
count = 0
|
| 91 |
-
if computerWin > playerWin:
|
| 92 |
st.write("Best of Three result: Sorry You lose!")
|
| 93 |
else:
|
| 94 |
st.write("Best of Three result: Yayy you win !")
|
| 95 |
-
computerWin = 0
|
| 96 |
-
playerWin = 0
|
| 97 |
|
|
|
|
| 21 |
elif (player_move == "Rock" and computer_move == "Scissors") or \
|
| 22 |
(player_move == "Paper" and computer_move == "Rock") or \
|
| 23 |
(player_move == "Scissors" and computer_move == "Paper"):
|
| 24 |
+
st.session_state.playerWin+=1
|
| 25 |
return "You win!"
|
| 26 |
else:
|
| 27 |
+
st.session_state.computerWin+=1
|
| 28 |
return "You lose!"
|
| 29 |
|
| 30 |
# Streamlit app
|
|
|
|
| 46 |
player_move = "Scissors"
|
| 47 |
|
| 48 |
# Ensure player_move is defined
|
| 49 |
+
if 'playerWin' not in st.session_state:
|
| 50 |
+
st.session_state.playerWin = 0
|
| 51 |
+
if 'computerWin' not in st.session_state:
|
| 52 |
+
st.session_state.computerWin = 0
|
| 53 |
+
|
| 54 |
if 'player_move' not in st.session_state:
|
| 55 |
st.session_state.player_move = None
|
| 56 |
|
|
|
|
| 93 |
|
| 94 |
if count == 3:
|
| 95 |
count = 0
|
| 96 |
+
if st.session_state.computerWin > st.session_state.playerWin:
|
| 97 |
st.write("Best of Three result: Sorry You lose!")
|
| 98 |
else:
|
| 99 |
st.write("Best of Three result: Yayy you win !")
|
| 100 |
+
st.session_state.computerWin = 0
|
| 101 |
+
st.session_state.playerWin = 0
|
| 102 |
|