File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -313,13 +313,8 @@ class Board {
313313
314314 if (!gameEnd)
315315 return " *" ;
316- if (result == 0 ) {
317- if (pos.material_counting ())
318- result = pos.material_counting_result ();
319-
320- if (result == 0 )
321- return " 1/2-1/2" ;
322- }
316+ if (result == 0 )
317+ return " 1/2-1/2" ;
323318 if (pos.side_to_move () == BLACK )
324319 result = -result;
325320 if (result > 0 )
Original file line number Diff line number Diff line change @@ -915,11 +915,6 @@ inline EnclosingRule Position::flip_enclosed_pieces() const {
915915
916916inline Value Position::stalemate_value (int ply) const {
917917 assert (var != nullptr );
918- if (var->stalematePieceCount )
919- {
920- int c = count<ALL_PIECES >(sideToMove) - count<ALL_PIECES >(~sideToMove);
921- return c == 0 ? VALUE_DRAW : convert_mate_value (c < 0 ? var->stalemateValue : -var->stalemateValue , ply);
922- }
923918 // Check for checkmate of pseudo-royal pieces
924919 if (var->extinctionPseudoRoyal )
925920 {
@@ -949,7 +944,17 @@ inline Value Position::stalemate_value(int ply) const {
949944 return convert_mate_value (var->checkmateValue , ply);
950945 }
951946 }
952- return convert_mate_value (var->stalemateValue , ply);
947+ Value result = var->stalemateValue ;
948+ // Is piece count used to determine stalemate result?
949+ if (var->stalematePieceCount )
950+ {
951+ int c = count<ALL_PIECES >(sideToMove) - count<ALL_PIECES >(~sideToMove);
952+ result = c == 0 ? VALUE_DRAW : c < 0 ? var->stalemateValue : -var->stalemateValue ;
953+ }
954+ // Apply material counting
955+ if (result == VALUE_DRAW && var->materialCounting )
956+ result = material_counting_result ();
957+ return convert_mate_value (result, ply);
953958}
954959
955960inline Value Position::checkmate_value (int ply) const {
Original file line number Diff line number Diff line change @@ -1082,6 +1082,17 @@ def test_game_result(self):
10821082 result = sf .game_result ("suicide" , "8/8/8/7p/7P/8/8/n7 w - - 0 1" , [])
10831083 self .assertEqual (result , sf .VALUE_MATE )
10841084
1085+ # armageddon
1086+ # black gets stalemated
1087+ result = sf .game_result ("armageddon" , "k7/P7/K7/8/8/8/8/8 b - - 0 1" , [])
1088+ self .assertEqual (result , sf .VALUE_MATE )
1089+ # white gets stalemated
1090+ result = sf .game_result ("armageddon" , "8/8/8/8/8/k7/p7/K7 w - - 0 1" , [])
1091+ self .assertEqual (result , - sf .VALUE_MATE )
1092+ # 50 move rule
1093+ result = sf .game_result ("armageddon" , "3n4/8/8/3k4/8/3K4/8/3BB3 w - - 100 80" , [])
1094+ self .assertEqual (result , - sf .VALUE_MATE )
1095+
10851096 # atomic check- and stalemate
10861097 # checkmate
10871098 result = sf .game_result ("atomic" , "BQ6/Rk6/8/8/8/8/8/4K3 b - - 0 1" , [])
Original file line number Diff line number Diff line change @@ -443,15 +443,9 @@ describe('board.result()', function () {
443443 board . pushSan ( "Kxd8" ) ;
444444 chai . expect ( board . result ( ) ) . to . equal ( "1/2-1/2" ) ;
445445
446- // Insufficient material with material counting - black draw odds (armageddon)
446+ // Stalemate with material counting - black draw odds (armageddon)
447447 board . delete ( ) ;
448448 board = new ffish . Board ( "armageddon" ) ;
449- board . setFen ( "3Rk3/8/8/8/8/8/2N5/3K4 b - - 0 1" ) ;
450- chai . expect ( board . result ( ) ) . to . equal ( "*" ) ;
451- board . pushSan ( "Kxd8" ) ;
452- chai . expect ( board . result ( ) ) . to . equal ( "0-1" ) ;
453-
454- // Stalemate with material counting - black draw odds (armageddon)
455449 board . setFen ( "2Q2bnr/4p1pq/5pkr/7p/7P/4P3/PPPP1PP1/RNB1KBNR w KQ - 1 10" ) ;
456450 chai . expect ( board . result ( ) ) . to . equal ( "*" ) ;
457451 board . pushSan ( "Qe6" ) ;
You can’t perform that action at this time.
0 commit comments