From: NicklasPersson Date: Mon, 2 Feb 2015 20:00:52 +0000 (+0800) Subject: Improved King Safety values X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=ddccb5355cabb7d1a9bf2c0fe3c51b3da0234260 Improved King Safety values From an SPSA-session on king safety. STC: ELO: 3.21 +-2.1 (95%) LOS: 99.8% Total: 40000 W: 8181 L: 7812 D: 24007 LTC: LLR: 2.95 (-2.94,2.94) [0.00,4.00] Total: 47765 W: 8091 L: 7785 D: 31889 Bench: 8589262 Resolves #241 --- diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 8e5a7f82..153e6eae 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -91,7 +91,7 @@ namespace { // Evaluation weights, indexed by evaluation term enum { Mobility, PawnStructure, PassedPawns, Space, KingSafety }; const struct Weight { int mg, eg; } Weights[] = { - {289, 344}, {233, 201}, {221, 273}, {46, 0}, {324, 0} + {289, 344}, {233, 201}, {221, 273}, {46, 0}, {322, 0} }; #define V(v) Value(v) @@ -186,15 +186,15 @@ namespace { // index to KingDanger[]. // // KingAttackWeights[PieceType] contains king attack weights by piece type - const int KingAttackWeights[] = { 0, 0, 8, 4, 4, 1 }; + const int KingAttackWeights[] = { 0, 0, 7, 5, 4, 1 }; // Bonuses for enemy's safe checks const int QueenContactCheck = 89; - const int RookContactCheck = 72; - const int QueenCheck = 51; - const int RookCheck = 38; - const int BishopCheck = 5; - const int KnightCheck = 16; + const int RookContactCheck = 71; + const int QueenCheck = 50; + const int RookCheck = 37; + const int BishopCheck = 6; + const int KnightCheck = 14; // KingDanger[attackUnits] contains the actual king danger weighted // scores, indexed by a calculated integer number. @@ -412,10 +412,10 @@ namespace { // attacked and undefended squares around our king and the quality of // the pawn shelter (current 'score' value). attackUnits = std::min(74, ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]) - + 9 * ei.kingAdjacentZoneAttacksCount[Them] + + 8 * ei.kingAdjacentZoneAttacksCount[Them] + 25 * popcount(undefended) - + 10 * (ei.pinnedPieces[Us] != 0) - - mg_value(score) / 8 + + 11 * (ei.pinnedPieces[Us] != 0) + - mg_value(score) * 31 / 256 - !pos.count(Them) * 60; // Analyse the enemy's safe queen contact checks. Firstly, find the @@ -891,7 +891,7 @@ namespace Eval { void init() { - const double MaxSlope = 8.5; + const double MaxSlope = 8.7; const double Peak = 1280; double t = 0.0; diff --git a/src/pawns.cpp b/src/pawns.cpp index 032b637e..ef456307 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -63,33 +63,33 @@ namespace { // Weakness of our pawn shelter in front of the king by [distance from edge][rank] const Value ShelterWeakness[][RANK_NB] = { - { V( 99), V(23), V(24), V(54), V(85), V( 93), V(107) }, - { V(119), V( 2), V(28), V(72), V(96), V(104), V(114) }, - { V(103), V( 6), V(47), V(74), V(84), V(103), V( 94) }, - { V( 78), V(10), V(41), V(64), V(88), V( 92), V(115) } }; + { V( 99), V(20), V(26), V(54), V(85), V( 92), V(108) }, + { V(117), V( 1), V(27), V(71), V(94), V(104), V(118) }, + { V(104), V( 4), V(51), V(76), V(82), V(102), V( 97) }, + { V( 80), V(12), V(43), V(65), V(88), V( 91), V(115) } }; // Danger of enemy pawns moving toward our king by [type][distance from edge][rank] const Value StormDanger[][4][RANK_NB] = { - { { V( 0), V( 65), V( 125), V(37), V(30) }, - { V( 0), V( 57), V( 136), V(39), V(24) }, - { V( 0), V( 50), V( 114), V(45), V(29) }, - { V( 0), V( 58), V( 129), V(56), V(34) } }, - { { V(20), V( 45), V( 91), V(47), V(20) }, - { V(25), V( 23), V( 105), V(38), V(14) }, - { V(21), V( 37), V( 99), V(35), V(21) }, - { V(30), V( 18), V( 105), V(38), V(28) } }, - { { V( 0), V( 0), V( 81), V(13), V( 4) }, - { V( 0), V( 0), V( 169), V(30), V( 4) }, - { V( 0), V( 0), V( 166), V(24), V( 6) }, - { V( 0), V( 0), V( 164), V(24), V(11) } }, - { { V( 0), V(-289), V(-297), V(57), V(29) }, - { V( 0), V( 66), V( 136), V(43), V(16) }, - { V( 0), V( 66), V( 141), V(50), V(31) }, - { V( 0), V( 63), V( 126), V(52), V(23) } } }; + { { V( 0), V( 65), V( 126), V(36), V(30) }, + { V( 0), V( 55), V( 135), V(36), V(23) }, + { V( 0), V( 47), V( 116), V(45), V(26) }, + { V( 0), V( 62), V( 127), V(57), V(34) } }, + { { V(21), V( 45), V( 93), V(50), V(19) }, + { V(23), V( 24), V( 105), V(41), V(13) }, + { V(23), V( 36), V( 101), V(38), V(20) }, + { V(30), V( 19), V( 110), V(41), V(27) } }, + { { V( 0), V( 0), V( 81), V(14), V( 4) }, + { V( 0), V( 0), V( 169), V(30), V( 3) }, + { V( 0), V( 0), V( 168), V(24), V( 5) }, + { V( 0), V( 0), V( 162), V(26), V(10) } }, + { { V( 0), V(-283), V(-298), V(57), V(29) }, + { V( 0), V( 63), V( 137), V(42), V(18) }, + { V( 0), V( 67), V( 145), V(49), V(33) }, + { V( 0), V( 62), V( 126), V(53), V(21) } } }; // Max bonus for king safety. Corresponds to start position with all the pawns // in front of the king and no enemy pawn on the horizon. - const Value MaxSafetyBonus = V(252); + const Value MaxSafetyBonus = V(258); #undef S #undef V