use sashite_feen::{encode, Feen, Side};
fn main() -> Result<(), sashite_feen::ParseError> {
let start = "-rnbqk^bn-r/+p+p+p+p+p+p+p+p/8/8/8/8/+P+P+P+P+P+P+P+P/-RNBQK^BN-R / W/w";
let feen = Feen::parse(start)?;
println!(
"Parsed a {}-square board holding {} pieces; {} to move.",
feen.square_count(),
feen.piece_count(),
describe(feen.active_side()),
);
println!("Shape: {:?}", feen.shape());
let position = feen.to_qi();
assert_eq!(encode(&position), start);
let pawn = *position.square(52).expect("a pawn on the e-file");
let after = position
.board_diff([(52, None), (36, Some(pawn))])
.expect("both squares are on the board")
.toggle();
println!("\nAfter relocating the e-pawn:\n{}", encode(&after));
Ok(())
}
fn describe(side: Side) -> &'static str {
match side {
Side::First => "the first player (uppercase)",
Side::Second => "the second player (lowercase)",
}
}