niklasf / shakmaty

A Rust library for chess and chess variant rules and operations
https://docs.rs/shakmaty
GNU General Public License v3.0
210 stars 41 forks source link

Using `Move::Put` results in an illegal move #70

Closed davebrent closed 1 year ago

davebrent commented 1 year ago

The following snippet fails when I think it should pass

let pos = Chess::default();
assert!(pos.is_legal(&Move::Put {
    role: Role::Pawn,
    to: Square::D4
}));

In the method, the move list does contain the valid move, but it has constructed a type of Move::Normal so the .contains(m) fails when using Move::Put

fn is_legal(&self, m: &Move) -> bool {
    ...
    moves.contains(m)
}
niklasf commented 1 year ago

Move::Put refers to the chess variant Crazyhouse, where players can take a captured piece out of their pocket and put it on the board.

I was going to link the documentation, but it is nowhere clearly stated. Will fix.