Module hexe_core::board::bitboard
[−]
[src]
A bitmap chess board representation.
Bitboards conveniently represent chess boards as 64-bit integers. Each bit represents an individual square. Occupancy is represented by the value of each bit.
For example, given a bitboard for all pawns and a bitboard for all whites, we can get all white pawns via a bitwise 'and' operation on the two sets:
Pawns: White:
. . . . . . . . . . . . . . . .
1 1 1 1 1 1 1 1 . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . & . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
. . . . . . . . 1 1 1 1 1 1 1 1
White Pawns:
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
1 1 1 1 1 1 1 1
. . . . . . . .
Bitboards can also be used to represent multiple piece move destinations simultaneously:
Knight attacks at D4:
. . . . . . . .
. . . . . . . .
. . 1 . 1 . . .
. 1 . . . 1 . .
. . . . . . . .
. 1 . . . 1 . .
. . 1 . 1 . . .
. . . . . . . .
This is actually how Square::D4.knight_attacks()
works internally:
via a lookup table.
Modules
masks |
Bitboard masks for each file and rank. |
Structs
Bitboard |
A mapping of sixty-four bits to squares of a chess board. |
CarryRippler |
An iterator over all subsets of a |
Enums
Direction |
A cardinal direction that can be used to shift or fill the bits of a
|