Crate shakmaty[−][src]
A library for chess move generation.
Examples
Generate legal moves in the starting position:
use shakmaty::{Chess, Position}; let pos = Chess::default(); let legals = pos.legals(); assert_eq!(legals.len(), 20);
Play moves:
use shakmaty::{Square, Move, Role}; // 1. e4 let pos = pos.play(&Move::Normal { role: Role::Pawn, from: Square::E2, to: Square::E4, capture: None, promotion: None, })?;
Detect game end conditions:
assert!(!pos.is_checkmate()); assert!(!pos.is_stalemate()); assert!(!pos.is_insufficient_material()); assert_eq!(pos.outcome(), None); // no winner yet
Also supports FEN, SAN and UCI formats for positions and moves.
Modules
attacks |
Attack and ray tables. |
fen |
Parse and write Forsyth-Edwards-Notation. |
san |
Read and write Standard Algebraic Notation. |
uci |
Parse and write moves in Universal Chess Interface representation. |
variants |
Chess variants. |
Structs
Bitboard |
A set of squares represented by a 64 bit integer mask. |
Board |
|
CarryRippler |
Iterator over the subsets of a |
Castles |
Castling paths and unmoved rooks. |
Chess |
A standard Chess position. |
IllegalMove |
Error in case of illegal moves. |
InvalidSquareName |
Error when parsing an invalid square name. |
Piece | |
Pieces |
Iterator over the pieces of a |
A players Crazyhouse pocket. |
|
Pockets |
Pockets to hold captured pieces for both sides (in Crazyhouse). |
PositionError | |
RemainingChecks |
The number of checks the respective side needs to give in order to win (in a game of Three-Check). |
Enums
CastlingSide |
|
Color |
|
Move |
Information about a move. |
Outcome |
Outcome of a game. |
Role |
Piece types: |
Square |
A square index. |
Traits
Position |
A legal chess or chess variant position. See |
Setup |
A not necessarily legal position. |
Functions
perft |
Counts legal move paths of a given length. |
Type Definitions
MoveList |
A container for moves that can be stored inline on the stack. |