From 44a571c1c7494503ee431ef6f974d030bf96af0d Mon Sep 17 00:00:00 2001 From: hxim Date: Mon, 9 Feb 2015 19:12:04 +0100 Subject: [PATCH 1/2] Fix KingDanger[] array initialization Use integer arithmetic instead of floating point arithmetic. Floating point arithmetic was causing different results for some 32-bit compiles No functional change Resolves #249 Resolves #250 --- src/evaluate.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index be3c6497..40d59648 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -912,14 +912,14 @@ namespace Eval { void init() { - const double MaxSlope = 8.7; - const double Peak = 1280; - double t = 0.0; + const int MaxSlope = 87; + const int Peak = 12800; + int t = 0; - for (int i = 1; i < 400; ++i) + for (int i = 0; i < 400; ++i) { - t = std::min(Peak, std::min(0.027 * i * i, t + MaxSlope)); - KingDanger[i] = apply_weight(make_score(int(t), 0), Weights[KingSafety]); + t = std::min(Peak, std::min(i * i * 27 / 100, t + MaxSlope)); + KingDanger[i] = apply_weight(make_score(t / 10, 0), Weights[KingSafety]); } } From a8f9c7a790883d2d31e108cd2739aefcfa5d919e Mon Sep 17 00:00:00 2001 From: snicolet Date: Fri, 13 Feb 2015 21:33:00 +0000 Subject: [PATCH 2/2] Small bonus for all safe pawn pushes Pawn flexibility: add a small bonus for all safe pawn pushes STC: LLR: 2.70 (-2.94,2.94) [-1.50,4.50] Total: 18233 W: 3705 L: 3557 D: 10971 LTC: LLR: 2.97 (-2.94,2.94) [0.00,6.00] Total: 17684 W: 3042 L: 2854 D: 11788 Bench: 7369224 Resolves #253 --- src/evaluate.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 40d59648..9d19ad75 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -163,6 +163,7 @@ namespace { const Score Unstoppable = S( 0, 20); const Score Hanging = S(31, 26); const Score PawnAttackThreat = S(20, 20); + const Score PawnSafePush = S( 5 , 5); // Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by // a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only @@ -547,14 +548,18 @@ namespace { score += more_than_one(b) ? KingOnMany : KingOnOne; } - // Add bonus for safe pawn pushes which attacks an enemy piece + // Add a small bonus for safe pawn pushes b = pos.pieces(Us, PAWN) & ~TRank7BB; b = shift_bb(b | (shift_bb(b & TRank2BB) & ~pos.pieces())); b &= ~pos.pieces() & ~ei.attackedBy[Them][PAWN] - & (ei.attackedBy[Us][PAWN] | ~ei.attackedBy[Them][ALL_PIECES]); + & (ei.attackedBy[Us][ALL_PIECES] | ~ei.attackedBy[Them][ALL_PIECES]); + + if (b) + score += popcount(b) * PawnSafePush; + // Add another bonus if the pawn push attacks an enemy piece b = (shift_bb(b) | shift_bb(b)) & pos.pieces(Them) & ~ei.attackedBy[Us][PAWN];