pub trait FromSetup: Sized {
fn from_setup(
setup: Setup,
mode: CastlingMode
) -> Result<Self, PositionError<Self>>;
}
Expand description
Validate and set up a playable Position
. All provided chess variants
support this.
Required Methods
fn from_setup(
setup: Setup,
mode: CastlingMode
) -> Result<Self, PositionError<Self>>
fn from_setup(
setup: Setup,
mode: CastlingMode
) -> Result<Self, PositionError<Self>>
Set up a playable Position
.
Errors
Returns PositionError
if the Setup
does not meet basic validity
requirements.
The requirements are chosen such that the position can be handled correctly by shakmaty, as well as other common chess software (in particular Stockfish and Lichess).
Meeting the requirements does not imply that the position is actually reachable with a series of legal moves from the starting position.
Examples
use shakmaty::{CastlingMode, Chess, FromSetup, Setup, PositionError};
let setup = Setup::default();
let pos = Chess::from_setup(setup, CastlingMode::Standard)
.or_else(PositionError::ignore_impossible_material)
.or_else(PositionError::ignore_impossible_check)?;