Refactor PSQ score calculation
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 28 Dec 2018 17:17:01 +0000 (18:17 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sun, 30 Dec 2018 18:23:51 +0000 (19:23 +0100)
Functional change, since the PSQT bonus is no longer divided
together with the piece value, but kept as is.

crazyhouse STC
LLR: 2.95 (-2.94,2.94) [-10.00,5.00]
Total: 279 W: 164 L: 101 D: 14
http://35.161.250.236:6543/tests/view/5c265b4e6e23db247289564d

crazyhouse LTC
LLR: 2.95 (-2.94,2.94) [-10.00,5.00]
Total: 372 W: 210 L: 147 D: 15
http://35.161.250.236:6543/tests/view/5c2665936e23db2472895651

giveaway STC
LLR: 2.98 (-2.94,2.94) [-10.00,5.00]
Total: 1353 W: 577 L: 528 D: 248
http://35.161.250.236:6543/tests/view/5c267e5a6e23db247289565c

giveaway LTC
LLR: 2.95 (-2.94,2.94) [-10.00,5.00]
Total: 286 W: 143 L: 88 D: 55
http://35.161.250.236:6543/tests/view/5c26aa0c6e23db2472895663

losers STC (failed)
LLR: -2.96 (-2.94,2.94) [-10.00,5.00]
Total: 1453 W: 610 L: 682 D: 161
http://35.161.250.236:6543/tests/view/5c267e676e23db247289565e

losers LTC (failed)
LLR: -2.98 (-2.94,2.94) [-10.00,5.00]
Total: 910 W: 366 L: 434 D: 110
http://35.161.250.236:6543/tests/view/5c273d4c6e23db247289566c

racingkings STC
LLR: 3.00 (-2.94,2.94) [-10.00,5.00]
Total: 2150 W: 760 L: 721 D: 669
http://35.161.250.236:6543/tests/view/5c266aba6e23db2472895657

racingkings LTC
LLR: 2.97 (-2.94,2.94) [-10.00,5.00]
Total: 1506 W: 523 L: 481 D: 502
http://35.161.250.236:6543/tests/view/5c2738616e23db2472895669

src/evaluate.cpp
src/psqt.cpp

index 1e7509f..7d816a8 100644 (file)
@@ -1031,13 +1031,7 @@ namespace {
     // Initialize score by reading the incrementally updated scores included in
     // the position object (material + piece square tables) and the material
     // imbalance. Score is computed internally from the white point of view.
-    Score score = pos.captures_to_hand() || !pos.checking_permitted() ? pos.psq_score() / 2 : pos.psq_score();
-    // For antichess-like variants, use negative piece values
-    if (  (   pos.extinction_value() == VALUE_MATE
-           && pos.extinction_piece_types().find(ALL_PIECES) != pos.extinction_piece_types().end()))
-        score = -score / 4;
-    else if (pos.bare_king_value() == VALUE_MATE)
-        score = make_score(-mg_value(score) / 4, -eg_value(score) / 8);
+    Score score = pos.psq_score();
     if (T)
         Trace::add(MATERIAL, score);
     score += me->imbalance() + pos.this_thread()->contempt;
index 7c26957..1b7a17f 100644 (file)
@@ -126,6 +126,17 @@ void init(const Variant* v) {
 
       Score score = make_score(PieceValue[MG][pc], PieceValue[EG][pc]);
 
+      // For drop variants, halve the piece values
+      if (v->capturesToHand || !v->checking)
+          score = score / 2;
+
+      // For antichess variants, use negative piece values
+      if (   v->extinctionValue == VALUE_MATE
+          && v->extinctionPieceTypes.find(ALL_PIECES) != v->extinctionPieceTypes.end())
+          score = -score / 8;
+      else if (v->bareKingValue == VALUE_MATE)
+          score = -score / 8;
+
       for (Square s = SQ_A1; s <= SQ_MAX; ++s)
       {
           File f = std::max(std::min(file_of(s), File(v->maxFile - file_of(s))), FILE_A);