[][src]Crate chess_move_gen

chess_move_gen

Provides structs and methods for generating chess moves efficiently

Example usage:

use chess_move_gen::*;
let mut list = MoveVec::new();
let position = &Position::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w QqKk - 0 1").unwrap();
legal_moves::<MoveVec>(position, &mut list);
assert_eq!(list.len(), 20);

Re-exports

pub use bb::BB;

Modules

bb

Structs

BestMoveTracker

BestMoveTracker implements MoveList and keeps a track of the best move seen so far

Board
Castle

Represents a castleove

CastlingRights

Represents the right to castle in a particular director for a particular side

Kind

Represents a kind of piece (eg knight)

KindsIter
Move

Represents a move on the chess position. Uses a compact 16 bit representation

MoveCounter

MoveCounter implements MoveList and keeps a count of different types of moves added to it.

MoveScore

MoveScore encodes a move score tuple

MoveVec

MoveVec implements MoveList and collects moves in a vector. Use iter to access the moves once they have been added.

Piece

Represents a piece for a particular side (eg black knight)

PieceSquareTable

PieceSquareTable gives scores for pieces on squares from the perspective of white. See https://www.chessprogramming.org/Piece-Square_Tables

PiecesIter
Position

Position encodes all positional information and non-positional game state

ScoredMoveList

ScoredMoveList is list move vec but calculates the piece-square score of each move as it adds them to the list This is more efficient than calculating scores later

Side

Represents a side to move

SortedMoveList

SortedMoveList is list move vec but calculates the piece-square score of each move as it adds them to the list This is more efficient than sorting scores later if you need the moves to be sorted according to piece-square score. Underlying structure is a binary heap which allows O(1) insertion and fast ordered interation via into_iter()

Square

Represents a square on the chessboard

SquaresIter
State

State encodes all game state except position

Constants

A1
A2
A3
A4
A5
A6
A7
A8
B1
B2
B3
B4
B5
B6
B7
B8
BISHOP
BLACK
BLACK_BISHOP
BLACK_KING
BLACK_KNIGHT
BLACK_KS
BLACK_PAWN
BLACK_QS
BLACK_QUEEN
BLACK_ROOK
C1
C2
C3
C4
C5
C6
C7
C8
D1
D2
D3
D4
D5
D6
D7
D8
E1
E2
E3
E4
E5
E6
E7
E8
F1
F2
F3
F4
F5
F6
F7
F8
G1
G2
G3
G4
G5
G6
G7
G8
H1
H2
H3
H4
H5
H6
H7
H8
KING
KING_SIDE
KING_SIDE_CASTLE
KNIGHT
NULL_KIND
NULL_MOVE
NULL_PIECE
PAWN
QUEEN
QUEEN_SIDE
QUEEN_SIDE_CASTLE
ROOK
STARTING_POSITION_FEN
WHITE
WHITE_BISHOP
WHITE_KING
WHITE_KNIGHT
WHITE_KS
WHITE_PAWN
WHITE_QS
WHITE_QUEEN
WHITE_ROOK

Traits

MoveList

MoveList represents a way to collect moves from move generation functions. Use this if you want to collect or record moves in a way not supported by MoveVec or MoveCounter

Functions

legal_moves

Adds all legal moves to the provided MoveList. Returns true if mover is in check

loud_legal_moves

Adds 'loud' legal moves to the provided MoveList. Returns true if mover is in check

perft

Returns the number of nodes at the provided depth cache_bytes_per_thread must be of form 2^N bytes if multi_threading_enabled is set to true search will run concurrently accross threads equal to your CPU count

perft_detailed

Returns the number of moves, captures, promotions, castles and en-passant captures at the provided depth if multi_threading_enabled is set to true search will run concurrently accross threads equal to your CPU count