niklasf / shakmaty

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

Correctly support Put #29

Closed antoyo closed 4 years ago

antoyo commented 4 years ago

Hi. It seems this library have support for the CrazyHouse variant, but it does not seem to work for me. Adding the following line here (even though it's probably not the correct fix) allows me to play CrazyHouse games:

                legals.push(Move::Put { role, to });

Thanks to fix this issue.

niklasf commented 4 years ago

Mhh ... this is exactly what's supposed to happen here: https://github.com/niklasf/shakmaty/blob/133c704a9ef9fc8d7b7b8a074d1229f28c33a56c/src/position.rs#L1197

Maybe some more context could help to try and reproduce this.

antoyo commented 4 years ago

Ah, I think I understand what is going on: I'm not actually using a CrazyHouse game, but a BugHouse game, so the pocket is probably not filled. Any workaround for that?

Edit: Since there's only one of the two games of BugHouse, we don't know which pieces are available.

niklasf commented 4 years ago

Unfortunately no. Since the implementation details are (intentionally) sealed, a crate implementing Bughouse on top of this one would have to reimplement parts of Crazyhouse or provide a wrapper that keeps setting up Crazyhouse positions with the current pockets.