Module alcibiades::bitsets [] [src]

Defines constants and functions for working with bitboards.

u64 bit-sets called bitboards can be used to represent a set of squares on the chessboard. This module defines utility functions and constants for working with u64 bit-sets.

Note: "LSB" means "least significant 1 bit".

Constants

BB_ALL

The set of all 64 squares on the board.

BB_FILE_A

The squares on file A.

BB_FILE_B

The squares on file B.

BB_FILE_C

The squares on file C.

BB_FILE_D

The squares on file D.

BB_FILE_E

The squares on file E.

BB_FILE_F

The squares on file F.

BB_FILE_G

The squares on file G.

BB_FILE_H

The squares on file H.

BB_MAIN_ANTI_DIAG

The squares on the main anti-diagonal (H1-A8).

BB_MAIN_DIAG

The squares on the main diagonal (A1-H8).

BB_NONE

Empty set of squares.

BB_RANK_1

The squares on rank 1.

BB_RANK_2

The squares on rank 2.

BB_RANK_3

The squares on rank 3.

BB_RANK_4

The squares on rank 4.

BB_RANK_5

The squares on rank 5.

BB_RANK_6

The squares on rank 6.

BB_RANK_7

The squares on rank 7.

BB_RANK_8

The squares on rank 8.

Functions

above_lsb

Returns a mask with all bits above the LSB set to 1.

above_lsb_including

Returns a mask with all bits above and including the LSB set to 1.

bb_anti_diag

Returns the set of squares on the same anti-diagonal as the given square.

bb_diag

Returns the set of squares on the same diagonal as the given square.

bb_file

Returns the set of squares on the same file as the given square.

bb_rank

Returns the set of squares on the same rank as the given square.

below_lsb

Returns a mask with all bits below the LSB set to 1.

below_lsb_including

Returns a mask with all bits below and including the LSB set to 1.

bsf

Returns the binary position of the LSB (bit-scan-forward).

bsf_reset

Returns the binary position of the LSB (bit-scan-forward), and resets the LSB to zero.

gen_shift

Shifts a value with a signed number.

lsb

Returns the LSB of a value.

pop_count

Returns the number of 1s in the binary representation of a value.

reset_lsb

Resets the LSB of a value to zero.