As I mentioned in previous questions I'm currently following this tutorial for building my chess engine.

The code was written in C#, but mine is in C++ and I'm in the phase of finalizing the board / piece / moves / valid moves representations without testing the logic just making sure the syntax is ok.

So I'm confused as to what should I do now, just continue writing without testing or there is a good way to test an incomplete chess engine?

Here you can take look at what I have done so far and your comments / recommendations are appreciated

2 Answers 2


I glanced at your code:

  • You should test your code with perft. Google it if you're not sure what it is.
  • Please make sure your code works before coding the engine search. If you unable to generate moves properly, nothing in your search will work.
  • Consider to use an array rather than a switch statement for piece values.
  • Consider to code your squares as an integer, not as a C++ class
  • Consider to collapse your WHITE and BLACK implementation together. C++ template would do that for you. Please take a look at Stockfish codebase if you're unsure.
  • I don't see you're making en passant in the code. Are you sure you have that covered?
  • Thank you @SmallChess for your glancing . The third point is an performance matter right ? for switching the logic from enumerated BLACK and WHITE to template color why is it better and yes I ignored En-passant for now (to-do).
    – Omar Hamed
    Jan 22, 2018 at 2:40
  • @HemedO.Khaled Very important for you to add en-passant. The performance points are good but not critical for you right now.
    – SmallChess
    Jan 22, 2018 at 4:57
  • 1
    @HemedO.Khaled Please consider accepting this nice answer if you feel it has covered your main concerns.
    – user929304
    Jan 22, 2018 at 12:48

Is there a good way to test an incomplete chess engine? Yes, but nothing of what I'm going to say is chess-specific but really just good software development practice. Write unit tests. This means test each "unit" of your program in isolation. The most common unit is a function. For example, let's say your program has a function to check whether a position is a checkmate. Set up a bunch of positions which you already know whether they are checkmate or not, call your function with each position, and verify that it returns the expected result. Keep those tests around and run them automatically as part of your development cycle. That way you'll notice immediately if you broke something by accident.

You can even write the test before actually writing the function that you want to test. That is called test-driven development.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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