Sep 28, 2019

Evolutionary Tic-Tac-Toe

This project attempts at evolving a perfect Tic-Tac-Toe player using an evolutionary algorithm where an initial generation of randomly generated players play against eachother with only the top 10% of the most fit players being allowed to pass their genes to the next generation.

In addition to the fitness function (Highest number of draws and wins), rare random mutation will occur with every generation to add diversity to the gene pool.

game screenshot

I developed the application with its algorithm using Java, while the interactive game is in JavaScript.

After 10k generations the player got noticeably better at making moves, but it wasn't that great. I believe it's possible to get better results after tweaking some parameters (Rate of mutation, number of parents, population size, etc) and running the algorithms for more generations.

I realize there are easier ways to create a perfect player for this game but this project was more of an educational experiment than a practical product.

Still, if you want to play against the latest generation you can do that here.

Check out the source code on GitHub here.