Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,9 +10,7 @@ model = genai.GenerativeModel('gemini-pro')
|
|
10 |
|
11 |
# Define the moves
|
12 |
moves = ["Rock", "Paper", "Scissors"]
|
13 |
-
|
14 |
-
playerWin = 0
|
15 |
-
computerWin = 0
|
16 |
|
17 |
# Function to determine the winner
|
18 |
def determine_winner(player_move, computer_move):
|
@@ -46,6 +44,8 @@ with col3:
|
|
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:
|
@@ -72,7 +72,7 @@ if "chat" not in st.session_state:
|
|
72 |
|
73 |
# If a move is selected, randomly choose a move for the computer and determine the result
|
74 |
if st.session_state.player_move:
|
75 |
-
count = count+1
|
76 |
player_move = st.session_state.player_move
|
77 |
response = st.session_state.chat.send_message(player_move)
|
78 |
computer_move = response.text
|
@@ -91,8 +91,8 @@ if st.session_state.player_move:
|
|
91 |
st.write("Result:")
|
92 |
st.subheader(result)
|
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:
|
|
|
10 |
|
11 |
# Define the moves
|
12 |
moves = ["Rock", "Paper", "Scissors"]
|
13 |
+
|
|
|
|
|
14 |
|
15 |
# Function to determine the winner
|
16 |
def determine_winner(player_move, computer_move):
|
|
|
44 |
player_move = "Scissors"
|
45 |
|
46 |
# Ensure player_move is defined
|
47 |
+
if 'count' not in st.session_state:
|
48 |
+
st.session_state.count = 0
|
49 |
if 'playerWin' not in st.session_state:
|
50 |
st.session_state.playerWin = 0
|
51 |
if 'computerWin' not in st.session_state:
|
|
|
72 |
|
73 |
# If a move is selected, randomly choose a move for the computer and determine the result
|
74 |
if st.session_state.player_move:
|
75 |
+
st.session_state.count = st.session_state.count+1
|
76 |
player_move = st.session_state.player_move
|
77 |
response = st.session_state.chat.send_message(player_move)
|
78 |
computer_move = response.text
|
|
|
91 |
st.write("Result:")
|
92 |
st.subheader(result)
|
93 |
|
94 |
+
if st.session_state.count == 3:
|
95 |
+
st.session_state.count = 0
|
96 |
if st.session_state.computerWin > st.session_state.playerWin:
|
97 |
st.write("Best of Three result: Sorry You lose!")
|
98 |
else:
|