Copyright 2016-2018, Caleb Evans
Released under the MIT License
You can play the app online at:
Like many traditional board game AIs, my Connect Four AI uses the minimax algorithm. For my particular implementation, I've chosen to use a maximum search depth of three (meaning the AI examines possibilities up to three turns into the future). This is combined with alpha-beta pruning to dramatically reduce the number of possibilities evaluated.
My scoring heuristic works by counting connections of chips that intersect with an empty slot, giving exponentially more weight to larger connections. For example, every single chip touching an empty slot is worth four points, a connect-two is worth nine points, a connect-three is worth sixteen points, and so on. A winning connection of four or more chips is given the maximum/minimum score.
In the app, the AI player is lovingly referred to as "Mr. AI".
Run the project locally
1. Install global dependencies
The project requires Node.js and Gulp, so make sure you have both.
brew install node
npm install -g gulp-cli
2. Install project dependencies
From the cloned project directory, run:
3. Serve app locally
To serve the app locally, run: