Skip to content

resolved the problem with main.py#142

Open
erenyeager101 wants to merge 1 commit intoshrawani21:mainfrom
erenyeager101:erenyeager101
Open

resolved the problem with main.py#142
erenyeager101 wants to merge 1 commit intoshrawani21:mainfrom
erenyeager101:erenyeager101

Conversation

@erenyeager101
Copy link

The issue in main.py is due to calling main() recursively inside the replay_game() function, which will cause a stack overflow and incorrect game logic.

To solve this, instead of calling main() again, reset the game variables within the same game loop so that it restarts cleanly.

Changes that i made:
Replay Logic: Added a reset_game() function that resets all the game variables, making the game restart smoothly when the "Replay" button is pressed.
Removed Recursive Call: The replay_game() function now only resets the game state instead of calling main() again, preventing recursive function calls.
Global Variables: Some variables like cells, fill_count, and players are now global so they can be reset properly when replaying the game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant