How to write a chess engine

Programming language

If you want to write your own chess engine you need at least some basic knowledge about a programming language. Most chess engines are written either in C or C++ but there are also a few others written in Java, Pascal or even in Assembler. C or C++ is probably the best choice. If you don't know C already it might be worth to learn it in order to create a chess engine. One of the best books to learn C is in my opinion 'The C Programming Language' from Kernighan & Ritchie. That book which is rather a slim book should be sufficient to learn C properly.

The right tools

In order to create the source files you need either an editor preferrably with syntax highlighting like Emacs, VIM or an IDE (Integrated Developement Enviroment) like Eclipse or Visual C/C++ from Microsoft. If you don't own a copy of MS Visual C/C++ already you don't need to spend any money in order to get a decent compiler. If you're running Windows you might want to download the MinGW suite with the GNU C/C++ compiler gcc or you could get the freecomandlinetools from Borland. There is also a compiler from Microsoft available for free which comes with an own ide and a debugger as well. If you happen to own a Linux box you won't have any problems at all as you should already have gcc on your system installed. For the Linux world is also a compiler from Intel availabe which is free for noncommerial use.

Documenting the sources

While I was writing on Roce I figured out that documenting the source code is very important. If the project keeps growing it's only a matter of time till you forget what this variable or that function exactly is supposed to do. Often I invented some variables on the fly just to test if something works as expected and forgot to delete these variables afterwards. Often I replaced some functions by other functions and forgot to take the old one out. In short, I had quite a mess in no time. So documenting the code certainly helps you to understand what you did a few weeks or months ago.

Theory first

In order to start writing your own engine you need to dive a bit into theory at first. Bruce Morelands site is a very good start to get an idea how MiniMax/Negamax and how Alpha Beta cut offs work. Once you read and understand that stuff you should also visit Ed Shröders site. The programmer of Rebel and Pro Deo has a website which I can highly recommend. But for the very beginner it might not be the right place to start.

A few important links for chess programmers:

Site of Bruce Moreland (deals mainly with chess programming)
Ed Shroeders site (deals with advanced topics of chess programming)

VIM: a nice editor with syntax highlighting
Link to MinGW (GNU gcc for windows)
Link to Borland's freecomandlinetools