feat(tic-tac-toe): add complete game with optimal Minimax-based AI #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This pull request introduces a complete Tic-Tac-Toe game featuring an unbeatable AI opponent powered by the Minimax algorithm.
The game runs entirely in the terminal with a clean text-based interface.
The AI evaluates every possible outcome to guarantee optimal play - it will never lose; the best a human can achieve is a draw.
Implementation details
The project is organized into modular components:
board/- manages the 3×3 game state stored as a 1D array (simplified indexing for positions 1–9)game.rs- implements the rules, turn logic, and win/draw detectionai/- contains the Minimax algorithm with depth-based evaluation and scoringrender/- handles terminal rendering and user inputEach module is independent and testable in isolation.
The code emphasizes readability, separation of concerns, and idiomatic Rust patterns.
Documentation
Detailed architecture and rationale are provided in
docs/architecture.md.The document focuses on why each design decision was made - module boundaries, AI scoring strategy, and trade-offs for simplicity and clarity.
Testing
A comprehensive test suite (32 tests) covers:
All tests pass (
cargo test), no lints fromclippyand the code is fully formatted withrustfmt.Usage