/ Alex Nuttall / blog

Connect Four

October 2, 2021

click the grid to start

source code

I wanted to have ago at programming a computer player, and I chose Connect Four for this purpose. Most of the computer’s moves are random, it only knows how to score a winning move (horizontally, vertically or diagonally) when the opportunity exists, and how to (try to) block your potential winning moves.

I would like to come back to this and add some analysis of sequences of two in terms of attacking and defending. When playing against a human opponent, deciding whether to defend against ‘twos’ is a big part of the game. I would like to give the computer some kind of default strategic behaviour. To make a good computer player, I’m sure you would need to analyse future steps, and not just the current game-state.