Getting Started
Home * Getting Started
Justgetting started with a new engine? Congratulations! You are in for a lot of fun, but there is a considerable amount of work ahead of you.
Contents
Building the Foundations
The foundation of a chess engine is theboard representation. This is the "back end" for the chess engine, which controls how it keeps track of the board and the rules of the game. Thevery first step to writing a chess engine is to write a complete,bug free board representation that knowsevery rule of chess. While this can sometimes be a pain, especially implementing the more complicated rules such ascastling andrepetition draws, it is the backbone of the chess engine, and your engine will not get far without it. Debugging tests such asPerft can be useful in verifying correctness of move generation.
When writing an engine, it is important to write bug free code. The best strategy when starting a new engine is to create a debugging framework under it so that every single piece of code gets tested, no matter how simple it looks. Many experienced engine authors have ended up rewriting their engines because they have become unmanageable due to bugs.
Search and Evaluation
Search andEvaluation are the "brains" behind a chess engine: they are what allows it to pick a good move. ANegamax framework withIterative Deepening and a pure material evaluation is a common starting place for a chess engine. But before you work further on Search and Evaluation, it is very important to prepare your engine for proper testing.
UCI and Time Management
A workingTime Management is important in that it both enables you to test your engine and makes it possible for the engine to compete and play under time control. The simplest, and surprisingly effective, way to manage time is to cap the search time at remaining time/20 + increment/2, after which the search aborts.
UCI (Universal Chess Interface) is the standard protocol for engine communication. Not only does it allow you to connect your program to aGUI (Graphical User Interface), but it also enables proper and scientific testing of your engine using tools such asOpenBench,cutechess-cli andfast-chess. Only asmall subset of UCI needs to be supported to facilitate these testing.
Scientific Development
No matter what your goals are in writing your engine, it isextremely important to test your engine in a scientific and rigorous way.
Most modern engines use self-playSPRT to determine the validity of a patch. SPRT is commonly regarded as the best and most efficient way to reach statistical certainty on whether a modification gains Elo or not. Many new engine developers get stuck at the lower end of rating lists due to no or improper testing.
Useful Resources
If you want ideas and see how other programmers have done things, take a look atSearch Progression and some of theOpen Source Engines. These can be very helpful when translating rather vague algorithms into specific data structures and code. Just be careful, and don't copy the code and say it is your own!Clones are frowned upon by the computer chess community as a whole.
It is also a very good idea to join some of theseComputer Chess Forums orDiscord Channels. The chess programming community is very friendly and will help you out with personalized advice. We are always happy to accept new members!
Some other good computer chess references can be found inRecommended Reading.

