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.legal_moves(); 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.
Feature flags
variant
: Enablesshakmaty::variant
module for all Lichess variants.
Re-exports
pub use crate::bitboard::Bitboard; |
Modules
attacks | Attack and ray tables. |
bitboard | Sets of squares. |
fen | Parse and write Forsyth-Edwards-Notation. |
san | Read and write Standard Algebraic Notation. |
uci | Parse and write moves in Universal Chess Interface representation. |
variant | variant Chess variants. |
Structs
Board |
|
ByColor | Container with values for each |
Castles | Castling paths and unmoved rooks. |
Chess | A standard Chess position. |
MaterialSide | The material configuration of one side. |
ParseMaterialError | Error when parsing an invalid material key. |
ParseSquareError | Error when parsing an invalid square name. |
Piece | |
Pieces | Iterator over the pieces of a |
PlayError | Error when trying to play an illegal move. |
PositionError | Error when trying to create a |
PositionErrorKinds | |
RemainingChecks | The number of checks the respective side needs to give in order to win (in a game of Three-Check). |
Enums
CastlingMode |
|
CastlingSide |
|
Color |
|
File | A file of the chessboard. |
Move | Information about a move. |
Outcome | Outcome of a game. |
Rank | A rank of the chessboard. |
Role | Piece types: |
Square | A square index. |
Traits
FromSetup | Validate and set up an arbitrary position. All provided chess variants support this. |
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
Material | The material configuration of both sides. |
MoveList | A container for moves that can be stored inline on the stack. |