1

I'm writing a chess engine, and I'm testing that the move generator is working correctly using a perft() function. In perft position 2 my engine appears to be 90 moves short at ply 2. How do authors of other engines then debug their engines? Is there a full list of perft moves available online somewhere?

The obvious issue with using an established engine to enumerate the moves is if there's a bug in the move generation function in the established engine.

1

The obvious issue with using an established engine to enumerate the moves is if there's a bug in the move generation function in the established engine.

Stockfish is always perfectly correct.

Goto https://github.com/official-stockfish/Stockfish/blob/master/src/search.cpp, add a std::cout in perft(). Recompile, and then run perft. Redirect your results to a text file.

Sort the results with: sort SFMoves.txt > SortedSFMoves.txt.

Similarly, repeat for your generator, sort it and then compare with Stockfish.

Common mistakes:

  • En-passpant
  • Underpromotion
  • Promote with a capture

Please check the special cases in your code.

  • Ok, I'm absolutely fascinated to see what I've missed - my assumption was that I'd be generating too many moves as I'm not preventing the moving of a piece that is pinned to the king yet. – Matt Parkins Oct 22 '18 at 11:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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