I started playing a lot of chess recently. As often happens with me, it wasn’t very long until I started wondering how I could Do Programming To It.
I found the mostly excellent, occasionally vague and confusing Chess Programming Wiki and have been using that as a guide. It helpfully says this on it’s Getting Started page:
The very first step to writing a chess engine is to write a complete, bug free board representation that knows every rule of chess.
As a software engineer, the “bug free” bit cracks me up.
My engine is called ChessFriend. It uses bitboards for its board representation. As of this post, I’ve managed to write a board representation that allows me to place pieces of both colors on any square, and I’m hacking away at the move generator. I’ve also written a small command line “board explorer” utility that can interact with my board representation. Of course, it has a pile of unit tests, helping me inch ever-so-slowly toward that blissful bug-free state.
It’s written in Rust. I’ve mostly avoided fighting with the borrow checker.