Picture of the physical game that we keep in the makerspace as inspiration

Learning to Play Connect4

--

Written by Ludy, Wouter & Jeroen

Connect4 series

Can we create an artificial brain (using Machine Learning) that can play the optimal strategy for the game Connect4? The idea to try this was based on a youtube video we saw by someone who use a neural net and a genetic algorithm to solve the game Snake, see https://www.youtube.com/watch?v=zIkBYwdkuTk

Connect4 is the game where you have a field of typically 7 columns where you can drop two different color ‘coins’. These stack to 6 high, see the image at the top. Each player has coins of a color and the first player to reach 4 coins in a row wins. The row can be vertical, horizontal or diagonal.

It looks like a very simple game. Children typically play this. The idea is to start with randomly initialised neural nets, the brains of the players. The input to the neural net is the state of the board and the output is a probability for each of the 7 columns to position the next coin.

We would then have these players play against each other, give points for winning, and select the ‘best’ players after some games played. At the end of this generation the best players survive to the next generation. The ‘bad’ players are killed. We fill up the next generation with offspring of the surviving players. And then we iterate. Like in the Snake example.

In essence the genetic algorithm takes the place of back propagation and a gradient on a loss function which we typically use to train a neural net.

In future articles we will go into details of this process. We have been working on this for a couple of months in spare hours. And we have already learned a lot. We are not sure yet whether we are going to succeed, but at least we will learn by failing.

Screenshot of a game in generation 22, between player 399 (playing red) and 389 (playing yellow).

--

--

Emerging technologies & challenges

Thoughts about emerging technologies and some of the challenges related to them. The technology itself usually is not the problem (or the solution).