Module reason_othello::bitboard[][src]

Low-level bitboard operations.

For efficiency, Bitboard operations are unchecked and may cause undefined behavior if invalid data is passed.

Under the hood, all these operations work on u64 bitboards. By convention, the MSB is the upper-left of the board, and uses row-major order.

Structs

Bitboard

Holds a single bit per location on an Othello board. Wraps u64 for efficient bit-twiddling, but avoids mixing with numerics.

Bits

Iterator for the bits in a Bitboard.

Constants

BLACK_START

Starting bitboard for Black.

WHITE_START

Starting bitboard for White.

Functions

apply_move

Compute an updated board after a given move is made, returning new bitboards for the active player and the opponent. move_mask must be a one-hot bitboard indicating the move location. Undefined behavior if an invalid Othello board or move_mask is provided.

get_move_mask

Compute a mask of the legal moves for the active player from masks of the active player’s pieces and the opponent’s pieces. Undefined behavior if an invalid Othello board is specified.

score_absolute_difference

Score a board as: # my pieces - # opponent pieces. Faster than score_winner_gets_empties(), but less common. Undefined behavior if both players have a piece at the same location.

score_winner_gets_empties

Score a board as: # my spaces - # opponent spaces, where empty spaces are scored for the winner. Undefined behavior if both players have a piece at the same location.