Rewrite game phase for drop games
authorFabian Fichter <ianfab@users.noreply.github.com>
Sat, 15 Dec 2018 10:18:36 +0000 (11:18 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sat, 15 Dec 2018 10:25:30 +0000 (11:25 +0100)
Define game phase based on pieces in hand,
and score king danger independent of game phase.

shogi
LLR: 2.97 (-2.94,2.94) [0.00,10.00]
Total: 624 W: 357 L: 248 D: 19

minishogi
LLR: 2.96 (-2.94,2.94) [0.00,10.00]
Total: 468 W: 261 L: 161 D: 46

judkinshogi
LLR: 2.98 (-2.94,2.94) [-10.00,5.00]
Total: 508 W: 281 L: 217 D: 10

crazyhouse STC
LLR: 2.99 (-2.94,2.94) [-10.00,5.00]
Total: 613 W: 330 L: 267 D: 16
http://35.161.250.236:6543/tests/view/5c13f9786e23db7639060ce0

src/evaluate.cpp
src/material.cpp
src/variant.h

index 013e1ce..9fa6cb6 100644 (file)
@@ -533,6 +533,10 @@ namespace {
     // King tropism, to anticipate slow motion attacks on our king
     score -= CloseEnemies * (popcount(b1) + popcount(b2)) * (1 + pos.captures_to_hand() + !!pos.max_check_count());
 
+    // For drop games, king danger is independent of game phase
+    if (pos.captures_to_hand())
+        score = make_score(mg_value(score), mg_value(score)) / (1 + 3 * !pos.shogi_doubled_pawn());
+
     if (T)
         Trace::add(KING, Us, score);
 
index 45d2741..6ff6873 100644 (file)
@@ -135,7 +135,15 @@ Entry* probe(const Position& pos) {
   Value npm = std::max(EndgameLimit, std::min(npm_w + npm_b, MidgameLimit));
 
   // Map total non-pawn material into [PHASE_ENDGAME, PHASE_MIDGAME]
-  e->gamePhase = Phase(((npm - EndgameLimit) * PHASE_MIDGAME) / (MidgameLimit - EndgameLimit));
+  if (pos.captures_to_hand())
+  {
+      npm = VALUE_ZERO;
+      for (PieceType pt : pos.piece_types())
+          npm += (pos.count_in_hand(WHITE, pt) + pos.count_in_hand(BLACK, pt)) * PieceValue[MG][make_piece(WHITE, pt)];
+      e->gamePhase = Phase(PHASE_MIDGAME * (MidgameLimit - std::min(npm, MidgameLimit)) / MidgameLimit);
+  }
+  else
+      e->gamePhase = Phase(((npm - EndgameLimit) * PHASE_MIDGAME) / (MidgameLimit - EndgameLimit));
 
 #ifdef LARGEBOARDS
   // Disable endgame evaluation until it works independent of board size
index fc9314c..2c182a3 100644 (file)
@@ -63,7 +63,7 @@ struct Variant {
   Bitboard blackDropRegion = AllSquares;
   bool sittuyinRookDrop = false;
   bool dropOppositeColoredBishop = false;
-  bool shogiDoubledPawn = false;
+  bool shogiDoubledPawn = true;
   bool immobilityIllegal = false;
   // game end
   Value stalemateValue = VALUE_DRAW;