Hey! Sorry I'm a little late, but congrats on your move generator!JoAnnP38 wrote: ↑Thu Nov 03, 2022 7:44 pm In writing a chess engine for mostly the first time, I finally have my move generation somewhat complete and so I threw together a Perft test to compare my results with others. (Thanks, by the way for those who were nice enough to post node counts for others to compare.) Here are some of my timings for tests up to 6 ply and I was hoping that someone could weigh in on whether I am on the right track or whether I still have a lot of optimization or redesign to do. Currently, I am writing my engine in C#. It is single threaded running on an AMD Ryzen 5 4500U processor. My design currently uses a simple 64 element array as the board, and I am using piece lists to iterate through the pieces during move generation. For 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.
Results:
1: Elapsed = 00:00:00.0000166
2: Elapsed = 00:00:00.0002136
3: Elapsed = 00:00:00.0286717
4: Elapsed = 00:00:00.1139569
5: Elapsed = 00:00:02.8700864
6: Elapsed = 00:01:01.1239183
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.
Here are the bulk counted, single-threaded, no-hashing perft results for my move generator, Charon, (running in WSL on an 11th gen intel i7):
perft(1) - 0.000 seconds - 20 nodes visited.
perft(2) - 0.000 seconds - 400 nodes visited.
perft(3) - 0.000 seconds - 8902 nodes visited.
perft(4) - 0.001 seconds - 197281 nodes visited.
perft(5) - 0.010 seconds - 4865609 nodes visited.
perft(6) - 0.244 seconds - 119060324 nodes visited.
Charon uses a few patterns from Stockfish and many techniques from Hacker's Delight. It generates strictly legal moves. It is a bitboard generator. It uses PEXT on new intel processors and Magic otherwise for sliding attacks.
Although you may have already fixed this, I do have to say that dynamic allocation, when used repetitively, is very slow. It usually requires communication with your OS, as well as a linear search to find space on the heap. You want to ensure that you only dynamically allocate at the beginning of perft, if possible.
Best of luck in your endeavors!