Precomputing Chess Bitboards in Rust
One of the most critical factors in an engine’s strength at playing Chess is how well it evaluates a given position and decides which move to play. Engines almost universally do this by searching the tree of available moves from a given position and determining which move will shift the balance of the game the most in the engine’s favor.
Performing this computation is a pretty intense job. Especially if the engine is operating under time pressure, it’s imperative that the work of building a board position and computing the list of available moves be as efficient as possible.
Many chess engines attempt to front-load this work by precomputing bitboards representing commonly used operations. For example, an engine might have bitboards of all the squares a rook can move to from a given square, or a bitboard representing the A1 to H8 diagonal.