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
624 stars 195 forks source link

Missing Shatranj draw adjudication of K vs K #833

Open gbtami opened 4 weeks ago

gbtami commented 4 weeks ago

https://i.imgur.com/ZZP2LNv.png If I add this two cases to test_game_result(), the first will be OK but the second fails. K vs K should be adjudicated as draw.

        # shatranj bare king win
        result = sf.game_result("shatranj", "1k6/2R5/8/8/8/8/5r2/6K1 w - - 0 1", ["g1f2", "b8a8"])
        self.assertEqual(result, sf.VALUE_MATE)

        # shatranj double bare king draw
        result = sf.game_result("shatranj", "1k6/2R5/8/8/8/8/5r2/6K1 w - - 0 1", ["g1f2", "b8c7"])
        self.assertEqual(result, sf.VALUE_DRAW)

Result

======================================================================
FAIL: test_game_result (__main__.TestPyffish.test_game_result)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tamas/Fairy-Stockfish/test.py", line 1038, in test_game_result
    self.assertEqual(result, sf.VALUE_DRAW)
AssertionError: -32000 != 0

----------------------------------------------------------------------
Ran 20 tests in 1.215s

FAILED (failures=1)
yjf2002ghty commented 4 weeks ago

This is the wrong configuration in variants.cpp for shatranj. It also happens for all other variants that sets the following parameters:

        v->extinctionValue = -VALUE_MATE;
        v->extinctionClaim = true;
        v->extinctionPieceTypes = piece_set(ALL_PIECES);
        v->extinctionPieceCount = 1;
        v->extinctionOpponentPieceCount = 2;

For example, courier also has this problem.

image

This means that when it's a player to move and that player only has 1 piece on board while the opponent has 2 pieces on board, that player loses. This rule probably nullifies the K vs K draw adjudication.