Connect-4 is a classic two-player strategy game where players alternate turns dropping colored discs into a seven-column, six-row vertically suspended grid.
The objective is to be the first to form a horizontal, vertical, or diagonal line of four of one's own discs.
Connect-4 is a solved game, with the first player being able to force a victory with perfect play.
This project implements an AI to play Connect-4 using a neural network to evaluate game states, making it a challenging opponent for human players.
- AI that evaluates game states through a trained neural network.
- Strategic game play, requiring players to think both offensively and defensively.
- Graphical user interface using Pygame to play against the AI.
- Python 3.8 or higher
- PyTorch
- Pygame
- Pandas
- NumPy
-
Clone the repository:
-
Install the required packages:
pip install torch pip install pygame pip install pandas pip install numpy
Before playing against the AI, ensure that the neural network model is trained:
- Run Con4Train
python3 Con4Train.py
This will train the neural network and save the model's state for use by the game AI.
To start the game, run the Con4Main.py script after training the AI:
- Run Con4Train
python3 Con4Main.py