From e748f29bce2fd8a5b811965a885cad74df39c57a Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Wed, 26 Dec 2018 19:17:05 +0100 Subject: [PATCH] Rewrite king danger of pieces in hand Evaluate pieces in hand analogously to pieces on the board. crazyhouse STC LLR: 2.97 (-2.94,2.94) [0.00,10.00] Total: 1774 W: 936 L: 809 D: 29 http://35.161.250.236:6543/tests/view/5c2382e16e23db2472895629 crazyhouse LTC LLR: 2.94 (-2.94,2.94) [0.00,10.00] Total: 1041 W: 572 L: 456 D: 13 http://35.161.250.236:6543/tests/view/5c239b2c6e23db247289562c minishogi LLR: 2.98 (-2.94,2.94) [0.00,10.00] Total: 526 W: 303 L: 197 D: 26 shogi LLR: 3.02 (-2.94,2.94) [-10.00,5.00] Total: 1812 W: 892 L: 838 D: 82 --- src/evaluate.cpp | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 7b431fa..d817eb3 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -452,8 +452,15 @@ namespace { if (pos.piece_drops() && pos.count_in_hand(Us, pt)) { + Bitboard b = pos.drop_region(Us, pt) & ~pos.pieces() & (~attackedBy2[Them] | attackedBy[Us][ALL_PIECES]); + if (b & kingRing[Them]) + { + kingAttackersCount[Us] += pos.count_in_hand(Us, pt); + kingAttackersWeight[Us] += KingAttackWeights[std::min(pt, QUEEN)] * pos.count_in_hand(Us, pt); + kingAttacksCount[Us] += popcount(b & attackedBy[Them][KING]); + } Bitboard theirHalf = pos.board_bb() & ~forward_ranks_bb(Them, relative_rank(Them, Rank((pos.max_rank() - 1) / 2), pos.max_rank())); - mobility[Us] += DropMobility * popcount(theirHalf & ~(pos.pieces() | attackedBy[Them][ALL_PIECES]) & pos.drop_region(Us, pt)); + mobility[Us] += DropMobility * popcount(b & theirHalf & ~attackedBy[Them][ALL_PIECES]); } return score; @@ -546,7 +553,6 @@ namespace { + 143 * popcount(pos.blockers_for_king(Us) | unsafeChecks) * 64 / popcount(pos.board_bb()) - 848 * !(pos.count(Them) || pos.captures_to_hand()) - 9 * mg_value(score) / 8 - + 100 * (pos.piece_drops() ? pos.count_in_hand(Them, ALL_PIECES) : 0) + 40; // Transform the kingDanger units into a Score, and subtract it from the evaluation @@ -1047,7 +1053,7 @@ namespace { // Evaluate pieces in hand once attack tables are complete if (pos.piece_drops()) - for (PieceType pt = KNIGHT; pt < KING; ++pt) + for (PieceType pt = PAWN; pt < KING; ++pt) score += hand(pt) - hand(pt); score += (mobility[WHITE] - mobility[BLACK]) * (1 + pos.captures_to_hand() + pos.must_capture()); -- 1.7.0.4