My first attempt at a chess program, after over a month of reading up and programming, resulted in a very weak program that plays to the standard of a weakish club player. Once in a while it even drops a piece, presumably due to some bug in the code. Even the move generator for this first program could only churn out a measly 2million nps in perft (for kiwiPete) - and the program is written in (very bad) c++.
My second attempt at a chess program has now run into a strange problem. In the kiwiPete position, http://chessprogramming.wikispaces.com/Perft+Results, I found the node count to be incorrect for depth 4. Thus I used divide and found one of the problematic branches. At depth 1 in the branch, the problem was still there. Then, after I identified a problematic sub-branch and used divide/perft at depth 2, the total node count for this subbranch is actually correct and not the same as the node count for this subbranch from one level up! I checked this for all branches, and it was the same result.
For all the branches that I can see are wrong from divide, once I manually makeMove(), and go into them the node counts inexplicably change to the correct ones. The problem of course is that the original perft is still bugged - but how do I debug the program now? My function verifyBoard() also returns no problems after each unmakeMove(), so I'm stumped. Has anyone ever encountered a similar bug?

