Struct shogi::Position [] [src]

pub struct Position { /* fields omitted */ }

Represents a state of the game.

Examples

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

let mut pos = Position::new();
pos.set_sfen("lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1").unwrap();

let m = Move::Normal{from: Square::new(2, 6), to: Square::new(2, 5), promote: false};
pos.make_move(&m).unwrap();

assert_eq!("lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1 moves 7g7f", pos.to_sfen());

Methods

impl Position
[src]

Creates a new instance of Position with an empty board.

Returns a piece at the given square.

Sets a piece at the given square.

Returns the number of the given piece in hand.

Returns the side to make a move next.

Returns the number of plies already completed by the current state.

Returns a history of all moves made since the beginning of the game.

Checks if the king with the given color is in check.

Makes the given move. Returns Err if the move is invalid or any special condition is met.

Undoes the last move.

Returns a list of squares to where the given pieve at the given square can move.

Parses the given SFEN string and updates the game state.

Converts the current state into SFEN formatted string.

Trait Implementations

impl Debug for Position
[src]

Formats the value using the given formatter.

impl Default for Position
[src]

Returns the "default value" for a type. Read more

impl Display for Position
[src]

Formats the value using the given formatter.