Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Connect 4 Hand Gesture AI 🎮

An interactive, AI-powered Connect 4 game controlled entirely by hand gestures! Built using Python, OpenCV, MediaPipe, and Pygame, this project allows you to battle against a Minimax-based AI agent using nothing but your hands.

Features ✨

  • Hand Gesture Control: Play the game without touching your mouse or keyboard! Uses your webcam and MediaPipe to track hand movements.
  • Smart AI Opponent: Battle an AI powered by the Minimax Algorithm.
  • Alpha-Beta Pruning: Optimized decision-making through optional Alpha-Beta pruning, which drastically improves search speed.
  • Dynamic Skill Level: Choose the AI's search depth dynamically at the start of the game, letting you control the difficulty.
  • Real-Time Decision Tree Visualization: An interactive on-screen tracing log displays the AI's calculation process under the playing board, with mouse scroll capabilities.
  • Heuristics Scoring: The AI evaluates non-terminal board states using specialized window-based scoring rules.

Requirements 🛠️

Ensure you have the following Python libraries installed:

  • opencv-python (cv2)
  • mediapipe
  • pygame
  • numpy

You can install them via pip:

pip install opencv-python mediapipe pygame numpy

How to Play 🕹️

  1. Run the script:
    python Connect4.py
  2. When prompted in the console, enter the desired AI Search Depth (e.g., 3 or 4).
  3. Choose whether to enable Alpha-Beta Pruning (y/n).
  4. A Pygame window and a Webcam window will appear.
  5. Use your hand to control the game:
    • Move: Move your index finger left and right to select a column.
    • Drop Piece: Form a fist (fold fingers) to drop your piece into the highlighted column.
  6. Use the scroll wheel on your mouse over the game window to scroll through the AI's Minimax calculation tree!

Enjoy defeating the AI with the power of your hands! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages