Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -158,4 +158,15 @@ while game_state['rounds_played'] < NUM_ROUNDS and len(game_state['player_cards'
|
|
158 |
if winner == 'player':
|
159 |
game_state['player_cards'].extend([player_card, ai_card])
|
160 |
game_state['player_score'] += 2
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
if winner == 'player':
|
159 |
game_state['player_cards'].extend([player_card, ai_card])
|
160 |
game_state['player_score'] += 2
|
161 |
+
else:
|
162 |
+
game_state['player_cards'].append(player_card)
|
163 |
+
game_state['ai_cards'].append(ai_card)
|
164 |
+
|
165 |
+
game_state['rounds_played'] += 1
|
166 |
+
|
167 |
+
# Save game state to file
|
168 |
+
with open('game_state.txt', 'w') as f:
|
169 |
+
if not os.path.exists('game_state.txt'):
|
170 |
+
f.write('player_cards,ai_cards,player_score,ai_score,rounds_played\n')
|
171 |
+
f.write(','.join([str(game_state[key]) for key in game_state.keys()]) + '\n')
|
172 |
+
|