Redefine game phase for drop games
authorFabian Fichter <ianfab@users.noreply.github.com>
Sat, 6 Jul 2019 10:22:06 +0000 (12:22 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sat, 6 Jul 2019 10:22:06 +0000 (12:22 +0200)
crazyhouse STC
LLR: 2.97 (-2.94,2.94) [-10.00,5.00]
Total: 2070 W: 1033 L: 981 D: 56
http://35.161.250.236:6543/tests/view/5d1f37226e23db34f4206c75

crazyhouse LTC
LLR: 2.97 (-2.94,2.94) [-10.00,5.00]
Total: 1346 W: 680 L: 623 D: 43
http://35.161.250.236:6543/tests/view/5d1f665c6e23db34f4206c78

src/material.cpp

index 7d65145..8b29f4e 100644 (file)
@@ -143,10 +143,10 @@ Entry* probe(const Position& pos) {
   // Map total non-pawn material into [PHASE_ENDGAME, PHASE_MIDGAME]
   if (pos.captures_to_hand())
   {
-      npm = VALUE_ZERO;
+      Value npm2 = 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);
+          npm2 += (pos.count_in_hand(WHITE, pt) + pos.count_in_hand(BLACK, pt)) * PieceValue[MG][make_piece(WHITE, pt)];
+      e->gamePhase = Phase(PHASE_MIDGAME * npm / std::max(int(npm + npm2), 1));
   }
   else
       e->gamePhase = Phase(((npm - EndgameLimit) * PHASE_MIDGAME) / (MidgameLimit - EndgameLimit));