Echecs.Bitboard.Helper (Echecs v0.1.5)

Copy Markdown View Source

Low-level bit manipulation helpers for bitboards.

lsb/1 finds the least-significant set square (De Bruijn sequence, nil for empty) and pop_count/1 counts set bits; both are compiler-inlined. Directional shifts (shift_north/1 and siblings) mask file wraps via Echecs.Bitboard.Constants.

Summary

Functions

Returns the index (0-63) of the least significant bit. Returns nil if 0.

Returns the number of set bits (population count)

Shifts a bitboard in a direction. handles wrapping.

Functions

lsb(bb)

Returns the index (0-63) of the least significant bit. Returns nil if 0.

pop_count(bb)

Returns the number of set bits (population count)

shift_east(bb)

shift_north(bb)

Shifts a bitboard in a direction. handles wrapping.

shift_north_east(bb)

shift_north_west(bb)

shift_south(bb)

shift_south_east(bb)

shift_south_west(bb)

shift_west(bb)