/connectfourai

A command line Connect Four game. Has a minimax AI that uses an alpha-beta pruning algorithm.

Primary LanguageJava

Connect Four with Minimax AI

By Richard Zou

Work dated January 2012, added to GitHub November 2014.

Introduction

A simple command line Connect Four game. Has a minimax AI that uses an alpha-beta pruning algorithm. The project was initially done in Netbeans and has currently been ported to IntelliJ IDEA. Runs in Java >= 1.6.

This project was a large learning experience for me: it was one of my first programming projects. I initially created a simple AI for Connect Four back in 2010, and then improved it when I learned about minimax and alpha-beta pruning in 2012.

Play against an applet

Click on the link below to play against a Java applet (with GUI!) of this game.
The Java applet was developed in Greenfoot, which is a simple Java IDE that provides easy access to graphics and a good learning experience.

Press start to run the game. The game does not tell you when it ends; you will not be able to make another move if you lose or win. This was coded in 2012 so I have lost track of the Greenfoot source code and cannot modify it.

Link to the applet on greenfoot.org