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.

Structs

Bitboard

A set of squares represented by a 64 bit integer mask.

Board

Piece positions on a board.

CarryRippler

Iterator over the subsets of a Bitboard.

Chess

A standard Chess position.

IllegalMove

Error in case of illegal moves.

InvalidSquareName

Error when parsing an invalid square name.

Piece

A piece with Color and Role.

Pieces

Iterator over the pieces of a Board.

Pocket

A players Crazyhouse pocket.

Pockets

Pockets to hold captured pieces for both sides (in Crazyhouse).

PositionError

Reasons for a Setup not beeing a legal Position.

RemainingChecks

The number of checks the respective side needs to give in order to in (in a game of Three-Check).

Enums

CastlingSide

KingSide (O-O) or QueenSide (O-O-O).

Color

White or Black.

Move

Information about a move.

Outcome

Outcome of a game.

Role

Piece types: Pawn, Knight, Bishop, Rook, Queen, King.

Square

A square index.

Traits

Position

A legal chess or chess variant position. See Chess for a concrete implementation.

Setup

A not necessarily legal position.

Functions

perft

Counts legal move paths of a given length.

Type Definitions

MoveList

A container for legal moves that can be stored inline on the stack.