Connect Four

This is a version of the classic Connect 4 game, which I made for my son. The original idea was to get it to learn to beat you by using a game tree to record previous outcomes, but that often leads to games that aren't enjoyable because they're too difficult to beat. After implementing a simple algorithm I found that it's actually a reasonable challenge for a younger player. The "computer" first looks to see whether it can make a winning move, if not it checks whether it can block a winning move by the user, and if it can't do that either then it plays a random move - it doesn't look ahead or plan.

 

Game structure Game structure Game structure Game structure Game structure Game structure
Game structure Game structure Game structure Game structure Game structure Game structure
Game structure Game structure Game structure Game structure Game structure Game structure
Game structure Game structure Game structure Game structure Game structure Game structure
Game structure Game structure Game structure Game structure Game structure Game structure
Game structure Game structure Game structure Game structure Game structure Game structure
Game structure Game structure Game structure Game structure Game structure Game structure

If you want to see how this has been implemented, you can either view the source of this page or look at the Python version of the Connect 4 program, which is fully commented.