From 9d39bea6c1bd6c6610eb94e89f02ef178a4aa293 Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Sat, 12 Sep 2020 10:49:09 +0200 Subject: [PATCH] Adjust king PSQT based on pawn rank shogi STC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 865 W: 489 L: 374 D: 2 http://www.variantfishtest.org:6543/tests/view/5f5b2c286e23db221d9e9135 shogi LTC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 1244 W: 678 L: 558 D: 8 http://www.variantfishtest.org:6543/tests/view/5f5b5cf86e23db221d9e9145 --- src/psqt.cpp | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/src/psqt.cpp b/src/psqt.cpp index 40c13c7..67b8bdb 100644 --- a/src/psqt.cpp +++ b/src/psqt.cpp @@ -19,11 +19,13 @@ */ #include +#include #include "types.h" #include "bitboard.h" #include "piece.h" #include "variant.h" +#include "misc.h" namespace PSQT { @@ -177,12 +179,25 @@ void init(const Variant* v) { && v->extinctionPieceTypes.find(ALL_PIECES) != v->extinctionPieceTypes.end()) score = -make_score(mg_value(score) / 8, eg_value(score) / 8 / (1 + !pi->sliderCapture.size())); + // Determine pawn rank + std::istringstream ss(v->startFen); + unsigned char token; + Rank rc = v->maxRank; + Rank pawnRank = RANK_2; + while ((ss >> token) && !isspace(token)) + { + if (token == '/') + --rc; + else if (token == v->pieceToChar[PAWN] || token == v->pieceToChar[SHOGI_PAWN]) + pawnRank = rc; + } + for (Square s = SQ_A1; s <= SQ_MAX; ++s) { File f = std::max(File(edge_distance(file_of(s), v->maxFile)), FILE_A); Rank r = rank_of(s); psq[ pc][ s] = score + ( pt == PAWN ? PBonus[std::min(r, RANK_8)][std::min(file_of(s), FILE_H)] - : pt == KING ? KingBonus[std::min(r, RANK_8)][std::min(f, FILE_D)] * (1 + v->capturesToHand) + : pt == KING ? KingBonus[Utility::clamp(Rank(r - pawnRank + 1), RANK_1, RANK_8)][std::min(f, FILE_D)] * (1 + v->capturesToHand) : pt <= QUEEN ? Bonus[pc][std::min(r, RANK_8)][std::min(f, FILE_D)] : pt == HORSE ? Bonus[KNIGHT][std::min(r, RANK_8)][std::min(f, FILE_D)] : isSlider ? make_score(5, 5) * (2 * f + std::max(std::min(r, Rank(v->maxRank - r)), RANK_1) - v->maxFile - 1) -- 1.7.0.4