An AI agent that plays Connect Four using the Minimax search algorithm with heuristic evaluation to make optimal decisions.
This project implements a game-playing agent that searches the game tree of Connect Four to select the best possible move under perfect play assumptions. The focus is on game state evaluation, search optimization, and correctness of decision-making rather than UI or graphics.
- Minimax search for optimal move selection
- Heuristic evaluation function for non-terminal states
- Game tree exploration with configurable search depth
- Turn-based game simulation against a human player
- Clean separation between game logic and AI logic
The bot uses the Minimax algorithm, modeling Connect Four as a two-player, zero-sum, deterministic game with perfect information.
At each move:
- The game tree is expanded up to a fixed depth
- Terminal states are evaluated for wins/losses/draws
- Non-terminal states are scored using a heuristic evaluation function
- The move that maximizes the minimum possible loss is selected
The evaluation function scores board positions based on:
- Number of potential winning lines
- Control of central columns
- Threats of immediate wins or losses
This allows the bot to play competitively even when full game tree search is computationally infeasible.