pub struct Position { /* fields omitted */ }
Represents a state of the game.
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());
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 http://www.computer-shogi.org/wcsc26/rule.pdf for more detail.
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.
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.
Returns the "default value" for a type. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts the given value to a String
. Read more
type Error = !
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more