[][src]Module shakmaty::attacks

Attack and ray tables.

Example

use shakmaty::attacks;

let occupied = Bitboard::from(Rank::Sixth); // blocking pieces
let attacks = attacks::bishop_attacks(Square::C2, occupied);
// . . . . . . . .
// . . . . . . . .
// 0 0 0 0 0 0 1 0
// . . . . . 1 . .
// 1 . . . 1 . . .
// . 1 . 1 . . . .
// . . . . . . . .
// . 1 . 1 . . . .

assert!(attacks.contains(Square::G6));
assert!(!attacks.contains(Square::H7));

Functions

aligned

Tests if all three squares are aligned on a rank, file or diagonal.

attacks

Looks up attacks for piece on sq with occupied squares.

between

The squares between the two squares (bounds not included), or an empty Bitboard if they are not on the same rank, file or diagonal.

bishop_attacks

Looks up attacks for a bishop on sq with occupied squares.

bishop_mask

Gets the set of potential blocking squares for a bishop on sq.

king_attacks

Looks up attacks for a king on sq.

knight_attacks

Looks up attacks for a knight on sq.

pawn_attacks

Looks up attacks for a pawn of color on sq.

queen_attacks

Looks up attacks for a queen on sq with occupied squares.

ray

The rank, file or diagonal with the two squares (or an empty Bitboard if they are not aligned).

rook_attacks

Looks up attacks for a rook on sq with occupied squares.

rook_mask

Gets the set of potential blocking squares for a rook on sq.