Chess Devlog: Huge Performance Improvements
I just released v2.0.3 of https://github.com/brighamskarda/chess . And it has some huge improvements. It went from taking over 20 seconds to calculate perft 6 from the staring position to taking just 6.5 seconds with profile guided optimization enabled. Here are some of the changes I made. Performance Improvements Remove Square Validation There were three bitboard functions that had squares as parameters. Bitboard operations are meant to be low level and are called quite often. Removing the bit of code that checks if a square was valid in these functions was technically a breaking change, but it was reasonable tradeoff of speed vs correctness. Reducing Slice Growths This was definitely one of the biggest gains in performance. By pre-allocating all the memory a slice might need on creation I was able to eliminate a ton of expensive slice growths in the move generation sections of my code. Before Optimization moves := make ( [ ] Move , 0 ) moves = append ( moves , pawnMov...