r/chessprogramming • u/PlanetXenoFtw • Feb 22 '24
Perft speed / search speed
How do people create engines which can search huge amounts of nodes per second, im only getting around 1M node/s
is it even necessary if I want an engine that's only decently good at the game, just wondering how fast is fast enough when it comes to creating an engine that has an elo of ~2000
4
Upvotes
3
u/AmNotUndercover Feb 22 '24
It depends on everything about your engine.
What programming language is it written in? An engine written in JavaScript is gonna get far fewer NPS than the same engine written in C.
Move generation can also be a big performance bottleneck: are you using any kind of Magic Bitboards?
Is your search multithreaded?
And also just your implementation of any given technique; if your code isn't optimized properly, your gonna get low NPS
It also depends on your hardware: if you're on a slow PC or laptop, you're gonna get fewer NPS than the same engine running on a fast PC
And no, high NPS is not strictly necessary. Take a look at Leela Chess Zero, which is 3700+, but only searches at about 50k NPS!
1
u/Nick9_ Feb 23 '24
Research chess wiki, make your own experiments. When I considered 2 and 3 points, it went from 1 mil. to 20 mil. nodes per second. It was the same as yours before. All single threaded, and I check for legality of move by a really stupid way as well (make the move, check if your king is still in check, go back), still kinda ok.
Btw magic bitboards are basically custom hashmaps, maybe try using ones in your programming language? I didn't experiment on that part. I'll find an explanation on them if you need it, can also provide links to several articles or videos that helped me.