How mikygt21/tictactoe works
TicTacToe is an SFML desktop game where a player chooses an AI difficulty, clicks cells to play as X, and sees the match result and replay/menu options. The runtime flows through Application and its active scene; the game scene delegates match logic to Match and maps clicks into moves, while the presentation layer draws the board and controls. The README documents Easy, Medium and Hard AI behavior. Source excerpts show the application loop and input mapping; some scene and match interactions are supported by the README and source index rather than inspected implementation details.
Main entry points: GameScene.cpp Match scene · Application.cpp Application loop · BoardView.cpp Board rendering · Button.cpp UI buttons
Components 21
Application and scenes
- Program entry
src/main.cpp - Application loop
src/app/Application.cpp - Scene contract
src/app/IScene.h - Difficulty menu
src/app/MenuScene.cpp - Match scene
src/app/GameScene.cpp
Game domain
- Board state
src/core/Board.cpp - Win rules
src/core/Rules.cpp - Turn logic
src/core/Game.cpp - Match coordinator
src/core/Match.cpp - Move value
src/core/Move.h - Player interface
src/core/IPlayer.h
Player strategies
- Human strategy
src/players/HumanPlayer.h - AI strategy
src/players/AIPlayer.cpp
Presentation
- Click mapping
src/presentation/InputMapper.h - Board rendering
src/presentation/BoardView.cpp - UI buttons
src/presentation/Button.cpp - Board layout
src/presentation/BoardLayout.h - Text placement
src/presentation/TextUtil.h - UI configuration
src/presentation/UiConfig.h
Other components
- Human player
- SFML window
Connections 27
- Human player → Application loop: starts game
- Program entry → Application loop: runs
src/main.cpp - Application loop → SFML window: polls events
src/app/Application.cpp - Application loop → Difficulty menu: starts with
src/app/Application.cpp - Application loop → Scene contract: dispatches scene
- Difficulty menu → Match scene: selects difficulty
- Difficulty menu → UI buttons: uses controls
- Match scene → Match coordinator: coordinates match
- Match scene → Click mapping: maps clicks
- Click mapping → Move value: produces move
src/presentation/InputMapper.h - Match scene → Board rendering: draws board
- Match scene → UI buttons: uses controls
- Match scene → Text placement: formats status
src/app/GameScene.cpp - Match coordinator → Turn logic: coordinates turns
- Match coordinator → Player interface: polls players
- Turn logic → Board state: updates state
src/core/Game.cpp - Turn logic → Win rules: checks outcome
src/core/Game.cpp - AI strategy → Win rules: evaluates moves
src/players/AIPlayer.cpp - Human strategy → Player interface: implements
src/players/HumanPlayer.h - AI strategy → Player interface: implements
- Board rendering → Board state: reads state
- Board rendering → Board layout: uses geometry
- Click mapping → Board layout: uses geometry
src/presentation/InputMapper.h - Board rendering → UI configuration: uses styling
src/presentation/BoardView.cpp - UI buttons → UI configuration: uses styling
src/presentation/Button.cpp - UI buttons → Text placement: centers labels
src/presentation/Button.cpp - Application loop → UI configuration: sets window
src/app/Application.cpp