Cross-platform desktop app to play and analyze Connect Four. Comes with a fast AI powered by minimax and alpha–beta pruning, a clean GUI, and helpful hints about forced wins.
- Play vs. AI or watch AI move: Choose who goes first on a simple setup screen.
- Strong search: Minimax with alpha–beta pruning and a small transposition table speeds up analysis.
- Smarter move ordering: Searches center columns first to prune more effectively and play more human-like moves.
- Immediate-win checks: Detects mate-in-1 for the side to move and avoids root-level blunders that allow an immediate reply win.
- Heuristic evaluation: Scores lines of four based on counts (2/3 in a row with empties) and emphasizes center control.
- Polished UI: Modern dark theme, 3D disc effects, responsive window resizing, and clear status indicators.
- Non-blocking AI: Calculation runs on a background thread, keeping the UI responsive and animations smooth.
- Forced-win indicator: When applicable, clearly warns "AI detects forced win in N turns."
- Game model: A
Boardtracks a 7×6 grid, current player, legal moves, wins/draws, and applies moves. - Search: The
Solverruns minimax with alpha–beta pruning. It caches(position, depth)results in aHashMapto avoid recomputation. - Ordering: Candidate columns are ordered center-out to improve pruning and play strength.
- Tactics: Before full search, it checks for immediate winning moves; at the root it filters out moves that allow the opponent an instant win.
- Evaluation: For non-terminal nodes, a heuristic sums all 4-cell windows, rewarding threats (2/3 in a row with empties) and center occupancy; terminal wins/losses get large scores.
- Threading: AI move calculation is offloaded to a separate thread to prevent UI freezing.
- Depth: Default search depth is 9 plies; adjust in
src/app.rsif you want a faster or stronger AI.
- Requirements: Latest stable Rust toolchain.
- Build:
cargo build- Run:
cargo run- Setup: Pick who moves first (Human or AI).
- Play: Click a column to drop a piece.
- New Game returns to setup; Reset Board clears the current board.
- On Windows, if
icon.icoexists, it will be embedded; otherwise a transparent placeholder is used. - On macOS, the
.appicon is provided via bundling metadata; the runtime uses a default icon.
- Rust, egui/eframe for the native GUI
- env_logger + log for simple logging

