I'm trying to understand how Stockfish thinks, how it calculates the best move. I'm reading open source code, but it's not clear. I want to know, should I know some theory about algorithms to understand that code? Or is it possible without knowing anything? If there are important algorithms, please tell me what I should learn before reading source code.


If you are reading the code to become a better player, you won't have much luck. The tricks used are only useful when you have the memory and computational power of a machine.

If instead you are reading it to learn about chess programming, the following wiki is a great resource https://chessprogramming.wikispaces.com

  • I'm programmer, so i know that men can't calculate like computer )) It's interesting for me, how programs can examine positions, also this'll improve my knowledge about programming (by reading code). Thanks for answer. – Digmadentia-Ars Jun 13 '14 at 7:43

TSCP is well commented and a good place to learn how chess programs work http://www.tckerrigan.com/Chess/TSCP/


Before starting diving into stockfish why don't you checkout the smallest chess program in C called nanochess by Oscar Toledo. It has only one file main.c

Not the answer you're looking for? Browse other questions tagged or ask your own question.