- CMake to simplify cross-platform compilation
- Clone the repository
git clone https://github.com/emrecil/connect-four-cli
cd connect-four-cli
- Create a build directory
mkdir build
cd build
- Compile sources
cmake ..
make
To start the game run the following command
./ConnectFour
A start menu will appear where you can choose the players
After choosing an option the game will start. At the end you will be asked if you want to play again. Enter 1 to restart or any other number to exit the game.
The AI is based on the negamax algorithm, which works by calculating a weight for every possible move until the game is over and tries to maximize the score of the current player.
Since it would take to long to compute every possible move a maximum depth has to be defined. I set the depth to 8 (you can change the depth by modifying the value of MAX_DEPTH in negamax.h) since it hits a sweet spot between quick and hard to play against.
The speed can be further improved using alpha beta pruning and transposition tables which are both not yet implemented. Additional information on Negamax can be found on Wikipedia.