JoAnnP38 wrote: ↑Thu Nov 03, 2022 7:44 pmFor simplicity's sake, I am currently dynamically allocating a list to hold all of the generated moves, and this happens on every call to GenerateMoves. I suspect this needs to be changed to use a single array that is shared by all moves to eliminate the heap allocations. But I don't have concrete evidence of that yet.
Dynamic allocation on the heap like with malloc() in C and new in C++ should definitely be avoided.
However, if you can get C# to allocate the move list on the stack, it should be fine. I suppose that means allocating a local array in search() and forwarding a reference to it in GenerateMoves(). But I don't know C#.
A single large array is not a necessity. (It might be slightly faster since you can get a somewhat better utilisation of cache lines.)
While the node counts are all "correct" for these tests, I have to admit I am surprised by the exponential explosion in timings, especially when going from 4 to 5 or 6 ply. All constructive comments welcome.
Node counts grow exponentially, so total time will grow exponentially, too. To have a better idea of the speed, calculate nodes per second.
To compare your perft with another engine, you have to know whether you are counting the same thing. If your engine checks for legality by making the move, checking whether the position is legal (enemy king not in check), and unmaking the move, then your perft will be very much slower than if your engine checks legality without actually making the move (or only generates legal moves).