File tree Expand file tree Collapse file tree 4 files changed +25
-20
lines changed
Expand file tree Collapse file tree 4 files changed +25
-20
lines changed 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 @@ -940,11 +940,6 @@ inline EnclosingRule Position::flip_enclosed_pieces() const {
940940
941941inline Value Position::stalemate_value (int ply) const {
942942 assert (var != nullptr );
943- if (var->stalematePieceCount )
944- {
945- int c = count<ALL_PIECES>(sideToMove) - count<ALL_PIECES>(~sideToMove);
946- return c == 0 ? VALUE_DRAW : convert_mate_value (c < 0 ? var->stalemateValue : -var->stalemateValue , ply);
947- }
948943 // Check for checkmate of pseudo-royal pieces
949944 if (var->extinctionPseudoRoyal )
950945 {
@@ -974,7 +969,17 @@ inline Value Position::stalemate_value(int ply) const {
974969 return convert_mate_value (var->checkmateValue , ply);
975970 }
976971 }
977- return convert_mate_value (var->stalemateValue , ply);
972+ Value result = var->stalemateValue ;
973+ // Is piece count used to determine stalemate result?
974+ if (var->stalematePieceCount )
975+ {
976+ int c = count<ALL_PIECES>(sideToMove) - count<ALL_PIECES>(~sideToMove);
977+ result = c == 0 ? VALUE_DRAW : c < 0 ? var->stalemateValue : -var->stalemateValue ;
978+ }
979+ // Apply material counting
980+ if (result == VALUE_DRAW && var->materialCounting )
981+ result = material_counting_result ();
982+ return convert_mate_value (result, ply);
978983}
979984
980985inline 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