Echecs.Bitboard.MagicGenerator (Echecs v0.1.5)

Copy Markdown View Source

Finds magic numbers and attack tables for sliding pieces (rooks, bishops).

find_all_magics/0 searches magics in parallel worker tasks (see find_all_magics_serial/0 for the sequential variant) and returns data suitable for scripts/generate_magic_cache.exs, which writes the priv/magic_cache.bin file consumed at compile time by Echecs.Bitboard.Magic. Only needed when regenerating the cache.

Summary

Functions

Finds magic numbers for all squares for rooks and bishops. Returns a structure suitable for saving.

Finds magic numbers for all squares without spawning worker tasks.

Functions

attack_bishop(sq, block)

attack_rook(sq, block)

find_all_magics()

Finds magic numbers for all squares for rooks and bishops. Returns a structure suitable for saving.

find_all_magics_serial()

Finds magic numbers for all squares without spawning worker tasks.

find_magic(sq, piece_type)

mask_bishop(sq)

mask_rook(sq)