/connect-four-minimax

Primary LanguagePythonMIT LicenseMIT

Connect Four Game

This is a Python implementation of the classic Connect Four game. Players can play against an AI with adjustable difficulty levels or against another human player.

Features

  • Play against AI or another human player
  • 10 AI difficulty levels ranging from Very Easy to Legendary
  • Command-line interface
  • Minimax algorithm with alpha-beta pruning for AI moves

How to Play

  1. Run the game script
  2. Choose your opponent (AI or human player)
  3. If playing against AI, select the difficulty level
  4. Take turns dropping pieces into the columns
  5. The first player to connect four pieces horizontally, vertically, or diagonally wins!

AI Difficulty Levels

  1. Very Easy
  2. Easy
  3. Medium
  4. Hard
  5. Expert
  6. Master
  7. Impossible
  8. Inhuman
  9. Godlike
  10. Legendary

Note: Higher difficulty levels (9 and 10) may take up to 10 minutes for the AI to make a move.

Requirements

  • Python 3.x

Installation

  1. Clone this repository
  2. Navigate to the project directory
  3. Run the game using Python:
python main.py

Files

  • main.py: The main game script
  • Board.py: Contains the Board class for game board operations
  • ConnectFour.py: Contains the ConnectFour class for game logic
  • config.py: Configuration file with game constants

Contributing

Feel free to fork this project and submit pull requests with improvements or bug fixes.

License

MIT License