Struct shogi::position::Position[][src]

pub struct Position { /* fields omitted */ }
Expand description

Represents a state of the game.

Examples

use shogi::{Move, Position};
use shogi::bitboard::Factory as BBFactory;
use shogi::square::consts::*;

BBFactory::init();
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: SQ_7G, to: SQ_7F, 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());

Implementations

Creates a new instance of Position with an empty board.

Returns a piece at the given square.

Returns a bitboard containing pieces of the given player.

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 a player with the given color can declare winning.

See the section 25 in 世界コンピュータ将棋選手権 大会ルール for more detail.

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

Returns the position of the king with the given color.

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

Returns a list of squares at which a piece of the given color is pinned.

Undoes the last move.

Returns a list of squares to where the given piece 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

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.