From: Fabian Fichter Date: Sat, 15 Dec 2018 10:18:36 +0000 (+0100) Subject: Rewrite game phase for drop games X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=6f5236805efbbd9b18a301673f54cec725818927;p=fairystockfish.git Rewrite game phase for drop games 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 --- diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 013e1ce..9fa6cb6 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -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); diff --git a/src/material.cpp b/src/material.cpp index 45d2741..6ff6873 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -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 diff --git a/src/variant.h b/src/variant.h index fc9314c..2c182a3 100644 --- a/src/variant.h +++ b/src/variant.h @@ -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;