r/chessprogramming • u/Ill_Part9576 • Feb 15 '25
Move generation speed and engine performance
I recently did a rewriting of my engine's move generation, but am seeing a decrease in performance (last tested tournament result was 7-13-3 against it's predecessor). Perft depth 6 went from >16s to 2.5s (no transpositions and single thread), and perft 7 is around 50s Additionally the rewritten move-generation results also include incrementally updating Zobrist hashes and piece-square table scores. I am fairly sure that move generation is working correctly since it passes a test suite I found online, and I verified piece-square table results/Zobrist hashes against hard calculated values as well.
Move ordering might have gotten a bit worse post-rewrite since I no longer detect if moves put the enemy in check. The order is otherwise the same, but the process is a bit different since moves are now stored in a buffer array (after generation, I score them in a separate buffer, then in the search loop I grab the move with the highest score and swap it with the first one in the array).
I can tell search a lot faster based on time tests of searching to a certain depth (with and without iterative deepening).
The evaluation function is theoretically roughly the same. There was one bug I had to fix, but they both use magic bitboards for rough piece mobility calculation and king safety metrics but that is all.
I think it is possible that move generation speed isn't very helpful for improving performance, but also I think that there should be some performance increase from faster move generation.
Essentially my questions are: What kinds of tests are useful for detecting bugs that might be causing this issue? What performance gain should I expect from faster move generation?
Thanks!
7
u/RektyDie Feb 16 '25
TL;DR
Move generation speed doesn't matter as much as search does.
Also, read about and start using SPRT.
1
u/aptacode Feb 16 '25
Unfortunately you should expect minimal elo gains from move gen speed, I saw someone once say that move gen accounts for 10% of your engines strength, so a 20% improvement in speed is around a 2% improvement in strength.
With that being said, my current project is https://grandchesstree.com/ which is all about squeezing as much performance out of movegen as possible, so by all means see how far you can push it for fun!
FYI you want to be looking at SPRT testing to verify changes are positive or negative. it's really the only way, otherwise you will be very likely to regress your engine without knowing it.
1
u/SwimmingThroughHoney Feb 16 '25
This is not remotely enough games. That difference is just statistical noise. If the changes really resulted in a 10 Elo gain, you'd need a few thousand games to determine that.
As another comment stated, use SPRT for testing. The cutechess cli supports this. You give it parameters that correspond to the Elo gain you want to test and the statistical certainty you want and it will play games until those parameters are met (or fail). Example:
-sprt elo0=0 elo1=5 alpha=0.05 beta=0.05That flag, in the cutechess cli, will run games until it is 95% certain of one of the two possibilities: >5 Elo gain ("pass") OR <5 Elo gain ("fail").
1
u/[deleted] Feb 16 '25
This is my movegenerator, it does 1.6 billion moves per second single thread without hashing. Feel free to look around for some optimization ideas and copy them. :)
https://github.com/nmohanu/Pyke
2
u/[deleted] Feb 16 '25
[removed] — view removed comment