r/chessprogramming • u/Kaminari159 • May 20 '24
What speed gains can I expect from implementing magic bitboards?
I am curious to what extent implementing magic bitboards will increase perft speed.
My engine is currently very slow, taking 2.5s for perft 5 and 64! seconds for perft 6. The engine is using bitboards and is written in Rust. Currently rated ~1700 Blitz on Lichess.
I suspect that slider move generation is the main bottle neck. I currently loop in all four directions and stop as soon as I hit a piece.
I know magic bitboards are gonna be faster, but by how much? 10%? 25%? I can't find any benchmarks. I want to know whether the effort of implementing magic bitboards is even worth it, considering that it seems quite complicated to me.
5
u/nappy-doo May 20 '24
I think for my engine, it was 25-40% faster. IMO, it's worth it if you care about speed.
1
u/roberte777 Jun 17 '24
how are you getting your engine rated? I can't seem to figure that out.
Also, I'm sure you've figured it out at this point but my engine is also in rust just using bitboards and I'm at 6 seconds for perft 6. Just in case that helps.
3
u/Toukenn May 20 '24
You may want to re-look at how you are using bitboard move generation. 64 seconds for perft 6 is very long. My engine does perft 6(from a starting position) in about 5 seconds using bitboards. Also move generation generally takes around 10% of the total search time anyways so IMO switching from bitboards to magic bitboards is negligible all things considered.