Skip to content

AhmedMahmoudMetwally/Connect-4-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Connect-4 Game with Smart AI

License: MIT

๐Ÿ† Game Overview

Connect Four is a classic two-player strategy game:

  • Players take turns dropping colored discs (Red/Yellow) into a 6ร—7 grid.
  • Discs occupy the lowest available slot in a column.
  • The goal: Connect four of your discs vertically, horizontally, or diagonally.
  • Game ends when the board is full; the player with the most connected-fours wins.

๐Ÿค– AI Opponents

The game supports two advanced AI algorithms:

Algorithm Description
Minimax Evaluates all possible moves to an optimal depth. Thorough but slower.
Alpha-Beta Pruning Optimized Minimax that skips irrelevant branches for faster computation.

AI Features:

  • Configurable difficulty levels: Easy โ†’ Expert (depth 2โ€“8)
  • Real-time move evaluation per column
  • Interactive decision-making visualization

๐ŸŽฏ Features & Objectives

โœ… Interactive Game Board:

  • 6ร—7 grid with real-time piece visualization
  • Highlights current playerโ€™s potential move

โœ… AI Decision Panel:

  • Displays algorithm type, search depth, thinking time
  • Shows column-by-column move evaluation
  • Includes visual bar graph of AI evaluation

โœ… Game Setup Interface:

  • Choose game mode: Human vs Human, Human vs AI, AI vs AI
  • Select AI difficulty and algorithm

โœ… Game Outcome:

  • Clear victory announcement
  • Highlight winning combination for immediate feedback

โœ… Educational Value:

  • Learn Minimax and Alpha-Beta Pruning in action
  • Understand AI decision-making strategies

๐Ÿ›  Technical Details

  • Core Algorithms:

    • Minimax (basic AI)
    • Alpha-Beta Pruning (optimized AI)
  • Board Evaluation: Heuristic scoring of positions

  • Gameplay Mechanics:

    • Valid move checking
    • Win condition detection (horizontal, vertical, diagonal)
    • Turn management & animations

๐Ÿ’ก Screenshots / Demo

(Include screenshots of the board, AI panel, and setup menu here)


โšก Installation & Running

  1. Clone the repository:
git clone <your-repo-url>
cd Connect-4-game
  1. Install dependencies:
pip install numpy pygame
  1. Run the game:
python connect_four.py

๐ŸŒŸ Future Enhancements

  • Add sound effects and animations
  • Allow custom board sizes and piece colors
  • Implement online multiplayer mode
  • Add save/load game state functionality

๐Ÿš€ Why This Project?

This project is more than a game:

  • Combines strategy, AI, and interactive UI
  • Great for learning game AI concepts
  • Perfect for portfolio showcase with professional presentation

About

Project in Introduction to Artificial Intelligence

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages