Loading LLD design...
Design an object-oriented Tic Tac Toe game that supports two players (human or bot) taking turns on a configurable NxN board.
The system should validate moves, detect wins (row, column, diagonal) and draws, support undo, and allow pluggable bot strategies (random, minimax). The game orchestrator manages the lifecycle from start through play to game-over.
Two-player gameplay
Two players (human or bot) alternate placing X and O on a grid
Move validation
Reject moves on occupied cells or out-of-bounds positions
Win detection
After each move, check row, column, and both diagonals for a winning line
Draw detection
Detect a draw when all cells are filled with no winner
Undo move
Allow undoing the last move and reverting the turn
Configurable board size
Support NxN boards (default 3x3)
Bot player
Support a computer player with a pluggable strategy (random, minimax)
Before diving into code, clarify the use cases and edge cases. Understanding the problem deeply leads to better class design.
Identify the primary actions users will perform. For a parking lot: park vehicle, exit vehicle, check availability. Each becomes a method.
Who interacts with the system? Customers, admins, automated systems? Each actor type may need different interfaces.
What are the limits? Max vehicles, supported vehicle types, payment methods. Constraints drive your data structures.
What happens on overflow? Concurrent access? Payment failures? Thinking about edge cases reveals hidden complexity.