Skip to content

ykshdja/CONNECTFOURBOT

Repository files navigation

Connect Four AI Bot (Minimax Search)

An AI agent that plays Connect Four using the Minimax search algorithm with heuristic evaluation to make optimal decisions.

Overview

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.

Key Features

  • 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

Algorithm

The bot uses the Minimax algorithm, modeling Connect Four as a two-player, zero-sum, deterministic game with perfect information.

At each move:

  1. The game tree is expanded up to a fixed depth
  2. Terminal states are evaluated for wins/losses/draws
  3. Non-terminal states are scored using a heuristic evaluation function
  4. The move that maximizes the minimum possible loss is selected

Heuristic Evaluation

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.

Project Structure

Screenshot 2025-12-13 at 8 07 08 PM Screenshot 2025-12-13 at 8 07 57 PM

About

ConnectFourBot is a command-line Connect Four game using Minimax + Alpha beta pruning.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages