Consider double blocked squares in CTF evaluation
authorFabian Fichter <ianfab@users.noreply.github.com>
Sun, 19 Apr 2020 06:55:38 +0000 (08:55 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sun, 19 Apr 2020 06:55:38 +0000 (08:55 +0200)
racingkings STC
LLR: 2.97 (-2.94,2.94) [0.00,10.00]
Total: 1004 W: 387 L: 296 D: 321
http://www.variantfishtest.org:6543/tests/view/5e9b4ecf6e23db36d55f29cc

racingkings LTC
LLR: 2.95 (-2.94,2.94) [0.00,10.00]
Total: 1647 W: 504 L: 414 D: 729
http://www.variantfishtest.org:6543/tests/view/5e9b572b6e23db36d55f29d2

kingofthehill STC
LLR: 2.96 (-2.94,2.94) [0.00,10.00]
Total: 1849 W: 884 L: 765 D: 200
http://www.variantfishtest.org:6543/tests/view/5e9b4eb86e23db36d55f29c9

kingofthehill LTC
LLR: 2.96 (-2.94,2.94) [0.00,10.00]
Total: 1252 W: 602 L: 493 D: 157
http://www.variantfishtest.org:6543/tests/view/5e9b57236e23db36d55f29d0

src/evaluate.cpp

index 5f9bfce..11870c5 100644 (file)
@@ -906,26 +906,31 @@ namespace {
     if (pos.capture_the_flag(Us))
     {
         PieceType ptCtf = pos.capture_the_flag_piece();
-        Bitboard ctfPieces = pos.pieces(Us, pos.capture_the_flag_piece());
+        Bitboard ctfPieces = pos.pieces(Us, ptCtf);
         Bitboard ctfTargets = pos.capture_the_flag(Us) & pos.board_bb();
         Bitboard onHold = 0;
+        Bitboard onHold2 = 0;
         Bitboard processed = 0;
         // Traverse all paths of the CTF pieces to the CTF targets.
         // Put squares that are attacked or occupied on hold for one iteration.
-        for (int dist = 0; (ctfPieces || onHold) && (ctfTargets & ~processed); dist++)
+        for (int dist = 0; (ctfPieces || onHold || onHold2) && (ctfTargets & ~processed); dist++)
         {
-            score += make_score(2500, 2500) * popcount(ctfTargets & ctfPieces) / (1 + dist * dist);
+            int wins = popcount(ctfTargets & ctfPieces);
+            if (wins)
+                score += make_score(4000, 4000) * wins / (wins + dist * dist);
             Bitboard current = ctfPieces;
             processed |= ctfPieces;
             ctfPieces = onHold & ~processed;
-            onHold = 0;
+            onHold = onHold2 & ~processed;
+            onHold2 = 0;
             while (current)
             {
                 Square s = pop_lsb(&current);
                 Bitboard attacks = (  (PseudoAttacks[Us][ptCtf][s] & pos.pieces())
                                     | (PseudoMoves[Us][ptCtf][s] & ~pos.pieces())) & ~processed & pos.board_bb();
                 ctfPieces |= attacks & ~pos.pieces(Us) & ~attackedBy[Them][ALL_PIECES];
-                onHold |= attacks;
+                onHold |= attacks & ~((pos.pieces(Us) & attackedBy[Them][ALL_PIECES]) | attackedBy2[Them]);
+                onHold2 |= attacks;
             }
         }
     }