Make your own free website on Tripod.com

Connect 4

This program uses no OS specific calls so should work on any platform. Also, the string class in it is quite handy so maybe download it for the "swiss-army" C++ string class.

This is an exploration into artificial intelligence. There are many computer players. Each uses slightly different heuristics. When you set the computer's level you are essentially telling it how many moves to look ahead in the beginning (it looks ahead further as the game progresses). You can play human vs. human, human vs. computer, or computer vs. computer. When the computer fights itself you can set a different level and heuristic for each player.

In addition to the maxi-min heuristic searching, it also uses alpha-beta pruning to speed things up. As searches become pruned enough and it gets really fast, it will look ahead extra turns. When columns become filled and it calculates that it will be able to search n additional turns without the possibility of searching more state nodes than an empty board then it will search ahead n additional turns. This makes it very tough to win if you do not make good moves in the early game. It also searches only half the board's possible moves when it is symmetrical (symmetry pruning) and then randomly chooses which half to play on when it decides which seems best; this is a nice speed boost. When it finds two or more moves that seem equally good then it will choose one at random.

Download the source code today:



Mirrors:
Home