[][src]Crate shakmaty

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.

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.

variants

Chess variants.

Structs

Board

Piece positions on a board.

Castles

Castling paths and unmoved rooks.

Chess

A standard Chess position.

IllegalMoveError

Error in case of illegal moves.

Material

The material configuration of both sides.

MaterialSide

The material configuration of one side.

ParseMaterialError

Error when parsing an invalid material key.

ParseSquareError

Error when parsing an invalid square name.

Piece

A piece with Color and Role.

Pieces

Iterator over the pieces of a Board.

PositionError

Reasons for a Setup not beeing a legal Position.

RemainingChecks

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

TryFromFloatError

Error when float is out of range.

TryFromIntError

Error when integer is out of range.

Enums

CastlingSide

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

Color

White or Black.

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: Pawn, Knight, Bishop, Rook, Queen, King.

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 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 moves that can be stored inline on the stack.