Skip to content

Added Player vs Computer mode using Magic Square algorithm#19

Merged
subhamdas461 merged 2 commits into
subhamdas461:masterfrom
PThanushree:tp
Oct 23, 2025
Merged

Added Player vs Computer mode using Magic Square algorithm#19
subhamdas461 merged 2 commits into
subhamdas461:masterfrom
PThanushree:tp

Conversation

@PThanushree
Copy link
Copy Markdown
Contributor

This update introduces a new Player vs Computer (PvC) game mode.
The computer’s moves are generated using the Magic Square algorithm, allowing it to play intelligently by analyzing winning positions and blocking player moves effectively.

Key Updates

Added a PvC mode toggle alongside existing PvP mode
Implemented Magic Square algorithm for computer move logic

Updated UI to:

Show mode selection buttons (blue by default, green when active)
Confirm restart before switching modes
Ensured smooth game restart flow and correct mode persistence

Testing Performed

Verified switching between PvP and PvC shows confirmation prompt correctly
Confirmed computer moves follow optimal logic using Magic Square
Checked UI responsiveness and button state highlighting

@subhamdas461 Kindly merge My PR assigning HactoberFest label

@PThanushree
Copy link
Copy Markdown
Contributor Author

@subhamdas461 Kindly review my PR and merge and close PR. Please assign HactoberFest labels.

@subhamdas461 subhamdas461 self-assigned this Oct 22, 2025
@subhamdas461
Copy link
Copy Markdown
Owner

Hello @PThanushree, the code has some issues:

  • The two options to select game mode (vs human or vs AI) should be disabled once the game start. Now we can change in between and that brings bugs with it.
  • Whenever anyone wins the restart button is not working.
  • UI is popping out of screen. Try to keep in non-scrollable.

Thanks. 👍

@subhamdas461 subhamdas461 self-requested a review October 22, 2025 07:45
Copy link
Copy Markdown
Owner

@subhamdas461 subhamdas461 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes

@PThanushree
Copy link
Copy Markdown
Contributor Author

Changes Update:

Prevented the UI from scrolling out of the viewport.
Made the layout responsive and neat.
Mode selection disabled once the first move is made (gameStarted flag).
Restart button now fully resets the game without reloading the page.
Overlay disables board clicks after a win/draw.
checkResult now stops further moves and prevents changing the mode mid-game.
UI pop-up/scroll issue fixed.

@subhamdas461 Kindly review the PR and do close PR by assigning HactoberFest labels/tag.

@subhamdas461 subhamdas461 merged commit afbbffb into subhamdas461:master Oct 23, 2025
@subhamdas461 subhamdas461 added the enhancement New feature or request label Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants