Is AddMoves() still based on the "king capture" principle? It seems so in the upper code snippet but not in the lower one ...leanchess wrote: ↑Sat Dec 11, 2021 9:58 am So as not to completely lose my sanity, I started over using C# (and even got it to look not too ugly):
That works, but is obviously very slow.Code: Select all
ulong Perft(Move* start, int depth) { Move* end = start; if (!AddMoves(ref end)) return 0; if (depth == 0) return 1; ulong count = 0; for (Move* curr = start; curr != end; ++curr) { Make(*curr); count += Perft(end, depth - 1); Unmake(*curr); } return count; }
However, as soon as I try to do it by the book (see? I even named the function the same!):I am again getting perft(3) = 8890.Code: Select all
ulong Perft(Move* start, int depth) { Move* end = start; if (depth == 0) return 1; AddMoves(ref end); ulong count = 0; for (Move* curr = start; curr != end; ++curr) { Make(*curr); if (!IsInCheck()) count += Perft(end, depth - 1); Unmake(*curr); } return count; }
And again: perft(3) = 8890 looks pretty much like you are missing bishop captures ...
1.e4 a6 2.Bxa6
1.e4 Na6 Bxa6
1.e4 b5 2.Bxb5
1.d4 h6 2.Bxh6
1.d4 Nh6 2.Bxh6
1.d4 g5 2.Bxg5
and the same for 1.e3/1.d3 ... 8902 - 8890 = 12 ...
