Fix PSQT color symmetry for non-standard board sizes
authorFabian Fichter <ianfab@users.noreply.github.com>
Sat, 23 Feb 2019 09:32:43 +0000 (10:32 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sat, 23 Feb 2019 12:59:57 +0000 (13:59 +0100)
minishogi
LLR: 2.99 (-2.94,2.94) [-10.00,5.00]
Total: 584 W: 324 L: 259 D: 1

shogi
LLR: 2.96 (-2.94,2.94) [-10.00,5.00]
Total: 680 W: 363 L: 301 D: 16

src/psqt.cpp

index 78331c9..2c502fd 100644 (file)
@@ -145,7 +145,7 @@ void init(const Variant* v) {
           psq[ pc][ s] = score + (  pt == KING  ? KingBonus[std::min(r, RANK_8)][std::min(f, FILE_D)]
                                   : pt <= QUEEN ? Bonus[pc][std::min(r, RANK_8)][std::min(f, FILE_D)]
                                                 : make_score(5, 5) * (2 * f + std::max(std::min(r, Rank(v->maxRank - r)), RANK_1) - 8));
-          psq[~pc][~s] = -psq[pc][s];
+          psq[~pc][rank_of(s) <= v->maxRank ? relative_square(BLACK, s, v->maxRank) : s] = -psq[pc][s];
       }
       // pieces in pocket
       psq[ pc][SQ_NONE] = score + make_score(20, 20);