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
617 stars 193 forks source link

Handling of pseudo-final positions in bughouse #155

Open antoyo opened 4 years ago

antoyo commented 4 years ago

Hi. It seems wrong to me that a stalemate is considered to be a checkmate in bughouse. The following commands:

setoption name UCI_Variant value bughouse
position fen 7k/P1Q5/8/8/3KP3/8/1PPP1PPP/RNB2BNR w - - 1 25
setoption name MultiPV value 15
go mate 1

gives the following mates in one:

info depth 245 seldepth 2 multipv 1 score mate 1 nodes 207151 nps 912559 tbhits 0 time 227 pv a7a8q
info depth 245 seldepth 2 multipv 2 score mate 1 nodes 207151 nps 912559 tbhits 0 time 227 pv a7a8r
info depth 245 seldepth 2 multipv 3 score mate 1 nodes 207151 nps 912559 tbhits 0 time 227 pv f1c4
info depth 245 seldepth 2 multipv 4 score mate 1 nodes 207151 nps 912559 tbhits 0 time 227 pv c7f7

In my opinion, the last two should not be considered as checkmate because they are stalemate. Thanks to fix this issue.

ianfab commented 4 years ago

Thanks for the report. This behavior was implemented intentionally, since OTB what happens in case of stalemate is that the player can not move and his time runs out. However, I do not know how stalemate is handled in online/computer bughouse, so input on that is very welcome.

Something similar actually applies to checkmates that still can be parried by a piece drop, but where the player does not have a piece in hand. On FICS I think such a situation immediately ends the game, whereas OTB the player might still wait for a piece from the other board if the opponent does not sit, so I am not sure whether that behavior is intentional or a limitation, and how it should be treated in Fairy-Stockfish.

antoyo commented 4 years ago

This website states that stalemates and non-contact checkmate do not end the game:

The player is not considered to be stalemated (since it is possible to get a piece to drop) The player is not considered to be checkmated if he could block the check with a piece potentially in his stock.

Also, I don't know for FICS, but on chess.com, a checkmate that can be blocked does not end the game immediately.

ianfab commented 4 years ago

Thanks. I think from an evaluation perspective it is ok to treat stalemate as winning, because it forces the opponent to sit until he gets pieces. A proper solution of both the situations with stalemate as well as with checkmates that can still be blocked depends on #122 to be implemented, but I will keep this open as a reminder to tackle this as soon as that issue is solved.