fairy-stockfish / Fairy-Stockfish

chess variant engine supporting Xiangqi, Shogi, Janggi, Makruk, S-Chess, Crazyhouse, Bughouse, and many more
https://fairy-stockfish.github.io/
GNU General Public License v3.0
603 stars 189 forks source link

Sittuyin placement #371

Open Fulmene opened 2 years ago

Fulmene commented 2 years ago

According to Maung Maung Lwin's doc, the red side places all their pieces first, before black starts doing anything. After red is done, black THEN starts the placement.

1.2 The player with red pieces commences the game. He shall set the initial position of his own side first and then the player with the black pieces shall set the initial position of the other side. After setting the position, no player is allowed to correct the position again.

I suppose this might be able to be "hacked" in with passing moves like #343 but idk how feasible/safe/etc this'll be.

ianfab commented 2 years ago

Yes, the current behavior does not fully reflect OTB rules and was just the most practicable way to implement it, but at least consistent with implementations in cutechess and pychess GUI. The ugly hack with passing moves is nothing that should be used for any properly supported variant, it really is just a very crude workaround that might be used to at least somehow support variants that otherwise would be impossible. If a non-alternating setup phase is desired, I think this would currently need to be implemented separately from Fairy-Stockfish (although pyffish could perhaps still be used to query for legal setup moves), and then could start in Fairy-SF with a custom FEN when all pieces are placed.

gbtami commented 2 years ago

Yea, maybe we should handle this on pychess site similar to Janggi. First player put up their pieces, then click on "ready" button, then second player doing it the same way.

ianfab commented 2 years ago

Yes. A proper setup implementation in Fairy-SF in the sense of really being able to have multiple subsequent moves of the same color I would say is likely out of scope, at least unless maybe at some point SF switches to MCTS.

Therefore the only alternative I see to implementing it on the pychess side would be to use the above mentioned passing workaround. However, even in that case it would require special handling on the pychess side to skip the passing moves, so I am not sure if that would help. Still, it might be an option to have this as a second sittuyin variant, at least I am somewhat open to that.

If not using the passing move workaround, you could still query the legal moves (just switching colors in the input FEN), or alternatively expose the Position::drop_region in pyffish, if you want to avoid implementing the drop regions in pychess.

gbtami commented 2 years ago

Yes, implementing this in pychess seems theoretically possible, but not trivial. I'm happy with current Sittuyin implementation, so I don't plan to do it myself for sure :)

Fulmene commented 2 years ago

Yes, I'll keep this issue in mind, but I probably won't come back to it for a long time.