Expand description
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.step
: Implementsstd::iter::Step
forSquare
,File
, andRank
. Requires nightly Rust.
Re-exports
pub use crate::bitboard::Bitboard;
Modules
Attack and ray tables.
Sets of squares.
Parse and write Forsyth-Edwards-Notation.
Read and write Standard Algebraic Notation.
Parse and write moves in Universal Chess Interface representation.
variant
Chess variants.
Zobrist hashing for positions.
Structs
Iterator over ByColor
.
Castling paths and unmoved rooks.
A standard Chess position.
The material configuration of one side.
Error when parsing an invalid color name.
Error when parsing an invalid material key.
Error when parsing an invalid square name.
Error when trying to play an illegal move.
The number of checks the respective side needs to give in order to win (in a game of Three-Check).
Enums
Standard
or Chess960
.
KingSide
(O-O) or QueenSide
(O-O-O).
White
or Black
.
A file of the chessboard.
Information about a move.
Outcome of a game.
Error when parsing the outcome of a game.
A rank of the chessboard.
Piece types: Pawn
, Knight
, Bishop
, Rook
, Queen
, King
.
A square index.
Traits
Validate and set up an arbitrary position. All provided chess variants support this.
A not necessarily legal position.
Functions
Counts legal move paths of a given length.