lichess.org
Donate
Jet engine in Riga

Kaspars Eglitis

How to create a perfect chess engine

Chess engineSoftware Development
These days, everyone wants to make an AI.

Here is a brief tutorial:
https://youtu.be/MAlSjtxy5ak

Project planning entails establishing goals, setting benchmarks, etc. and most people are less interested in coding an engine from scratch, and more interested in using the latest technology even if they didn't code it. But in case you are part of the 1% of software developers who enjoy the grind... well, here's what I can share from my experience creating an engine from scratch decades ago.

1. Identify goals

A goal is finite, measurable, and reachable. Setting realistic goals such as:

  • Generate legal moves
  • Play random moves
  • Use a GUI such as GNU WinBoard/XBoard to play against a local or online opponent
  • Play random checks or captures

etc. empowers you with decision points, at which times you can choose to keep going, change course, or even abort your project if you decide that reinventing the wheel becomes dull & you'd rather just improve some other free software developer's wheel instead.

2. Solicit experts' opinions

If your project doesn't suck, chances are it's because you listened to feedback from experts and took their advice to heart. Or maybe you are a genius who figures out everything on their own, in which case there's probably some 2-year-old who made a better engine even faster. Better luck next time!

3. Respectfully use others' work

You don't need to make a UI from scratch any more than you need to make an operating system, keyboard driver, etc. from scratch. Take a minute to research what other free software experts have done, and while respecting (and not violating) their software licenses feel free to reuse and even contribute to make better software.

4. Appeal to standards

Others' work isn't limited to source code; databases, protocols, etc. are all standards which can facilitate collaboration. Yes, some standards (*cough* PGN) can be challenging to use, but reinventing the wheel is even more challenging

Here are some excellent resources I've searched for over the years:

Good luck and happy debugging!


Photo credit: Kaspars Eglitis