Crate shogi [] [src]

A library for implementing Shogi application.

shogi provides a various types and implementations for representing concepts and rules in Shogi. Most types can be created programatically while they can also be deserialized from / serialized to SFEN format. usi module provides APIs to deal with USI commands in a type-safe way. See http://www.geocities.jp/shogidokoro/usi.html for more detail about UCI protocol specification and SFEN format.

Examples

use shogi::{Color, Move, Position, Square};

let mut pos = Position::new();

// Position can be set from the SFEN formatted string.
pos.set_sfen("lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1").unwrap();

// You can programatically create a Move instance.
let m = Move::Normal{from: Square::new(2, 6), to: Square::new(2, 5), promote: false};
pos.make_move(&m).unwrap();

// Move can be created from the SFEN formatted string as well.
let m = Move::from_sfen("7c7d").unwrap();
pos.make_move(&m).unwrap();

// Position can be converted back to the SFEN formatted string.
assert_eq!("lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1 moves 7g7f 7c7d", pos.to_sfen());

Modules

usi

Types representing commands defined in USI protocol.

Structs

Hand

Manages the number of each pieces in each player's hand.

Piece

Represents a piece on the game board.

Position

Represents a state of the game.

SfenError

The error type for SFEN serialize/deserialize operations.

Square

Represents a position of each cell in the game board.

Enums

Color

Represents each side of player. Black player moves first.

Move

Represents a move which either is a normal move or a drop move.

MoveError

Represents an error occurred during making a move.

MoveRecord

MoveRecord stores information necessary to undo the move.

PieceType

Represents a kind of pieces.

TimeControl

Represents various time controls.