1-Hot Encoding: The Chess Programmer’s Secret Weapon

This is not my first rodeo.

I’ve built a chess engine before, but the results were… let’s say… underwhelming.

Don’t get me wrong, the program worked; it was able to play a full game of chess, and for that, I give it credit. But let’s face it, it was terrible at chess.

It took minutes to produce a move, even at a low search depth. And then, the moves it would output were random and unpredictable: sometimes it would force you into a neat mate-in-3, other times it would sacrifice a rook and then lose the game entirely.

I recently decided it’s time for round 2, and I thought I’d document my journey and share some things I learn in the process. There are so many different problems that arise, and so many different approaches to solving them. Of all the programming rabbit holes I’ve gotten lost down, chess programming is definitely one of my favourites.