Fix king ring for non-standard board sizes
authorFabian Fichter <ianfab@users.noreply.github.com>
Sun, 10 Nov 2019 21:51:26 +0000 (22:51 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sun, 10 Nov 2019 21:51:26 +0000 (22:51 +0100)
Adjust king danger for shogi variants to compensate for effect of fix.

src/evaluate.cpp

index 140c032..57887e4 100644 (file)
@@ -258,7 +258,7 @@ namespace {
 
     // Init our king safety tables
     kingRing[Us] = attackedBy[Us][KING];
-    if (pos.count<KING>(Us) && relative_rank(Us, ksq) == RANK_1)
+    if (pos.count<KING>(Us) && relative_rank(Us, ksq, pos.max_rank()) == RANK_1)
         kingRing[Us] |= shift<Up>(kingRing[Us]);
 
     if (pos.count<KING>(Us) && file_of(ksq) == pos.max_file())
@@ -577,7 +577,7 @@ namespace {
 
     // 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 + !pos.shogi_doubled_pawn());
+        score = make_score(mg_value(score), mg_value(score)) * 2 / (2 + 3 * !pos.shogi_doubled_pawn());
 
     if (T)
         Trace::add(KING, Us, score);