Crate shakmaty [] [src]

A library for chess move generation.

Examples

Generate legal moves in the starting position:

use shakmaty::Chess;
use shakmaty::Position;
use shakmaty::MoveList;

let pos = Chess::default();

let mut legals = MoveList::new();
pos.legal_moves(&mut legals);
assert_eq!(legals.len(), 20);

Play moves:

use shakmaty::Move;
use shakmaty::Role;
use shakmaty::square;

let pos = pos.play(&Move::Normal {
    role: Role::Pawn,
    from: square::E2,
    to: square::E4,
    capture: None,
    promotion: None,
}).expect("1. e4 is legal");

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.

Reexports

pub use square::Square;

Modules

attacks

Attack and ray tables.

fen

Parse and write Forsyth-Edwards-Notation.

perft

Count legal move paths.

san

Read and write Standard Algebraic Notation.

square

Square constants and distance functions.

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

Piece positions on a board.

CarryRippler

Iterator over the subsets of a Bitboard.

Chess

A standard Chess position.

Piece

A piece with Color and Role.

Pocket

A players Crazyhouse pocket.

Pockets

Crazyhouse pockets for both sides, holding captured pieces.

RemainingChecks

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

Enums

Color

White or Black.

Move

Information about a move.

Outcome

Outcome of a game.

PositionError

Reasons for a Setup not beeing a legal Position.

Role

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

Traits

Position

A legal chess or chess variant position. See Chess and shakmaty::variants for concrete implementations.

Setup

A (not necessarily legal) position.

Type Definitions

MoveList

A stack-allocated container to hold legal moves.