@@ -75,8 +75,8 @@ namespace {
7575 const int GrainSize = 8 ;
7676
7777 // Evaluation weights, initialized from UCI options
78- enum { Mobility, PassedPawns, Space };
79- Score Weights[3 ];
78+ enum { Mobility, PassedPawns, Space, KingDangerUs, KingDangerThem };
79+ Score Weights[6 ];
8080
8181 typedef Value V;
8282 #define S (mg, eg ) make_score(mg, eg)
@@ -88,7 +88,7 @@ namespace {
8888 //
8989 // Values modified by Joona Kiiski
9090 const Score WeightsInternal[] = {
91- S (252 , 344 ), S (216 , 266 ), S (46 , 0 )
91+ S (252 , 344 ), S (216 , 266 ), S (46 , 0 ), S ( 247 , 0 ), S ( 259 , 0 )
9292 };
9393
9494 // MobilityBonus[PieceType][attacked] contains mobility bonuses for middle and
@@ -197,10 +197,6 @@ namespace {
197197 // the strength of the enemy attack are added up into an integer, which
198198 // is used as an index to KingDangerTable[].
199199 //
200- // King safety evaluation is asymmetrical and different for us (root color)
201- // and for our opponent. These values are used to init KingDangerTable.
202- const int KingDangerWeights[] = { 259 , 247 };
203-
204200 // KingAttackWeights[PieceType] contains king attack weights by piece type
205201 const int KingAttackWeights[] = { 0 , 0 , 2 , 2 , 3 , 5 };
206202
@@ -287,16 +283,19 @@ namespace Eval {
287283
288284 void init () {
289285
290- Weights[Mobility] = weight_option (" Mobility (Middle Game)" , " Mobility (Endgame)" , WeightsInternal[Mobility]);
291- Weights[PassedPawns] = weight_option (" Passed Pawns (Middle Game)" , " Passed Pawns (Endgame)" , WeightsInternal[PassedPawns]);
292- Weights[Space] = weight_option (" Space" , " Space" , WeightsInternal[Space]);
293-
294- int KingDanger[] = { KingDangerWeights[0 ], KingDangerWeights[1 ] };
295-
296- // If running in analysis mode, make sure we use symmetrical king safety.
297- // We do so by replacing both KingDanger weights by their average.
286+ Weights[Mobility] = weight_option (" Mobility (Middle Game)" , " Mobility (Endgame)" , WeightsInternal[Mobility]);
287+ Weights[PassedPawns] = weight_option (" Passed Pawns (Middle Game)" , " Passed Pawns (Endgame)" , WeightsInternal[PassedPawns]);
288+ Weights[Space] = weight_option (" Space" , " Space" , WeightsInternal[Space]);
289+ Weights[KingDangerUs] = weight_option (" Cowardice" , " Cowardice" , WeightsInternal[KingDangerUs]);
290+ Weights[KingDangerThem] = weight_option (" Aggressiveness" , " Aggressiveness" , WeightsInternal[KingDangerThem]);
291+
292+ // King safety is asymmetrical. Our king danger level is weighted by
293+ // "Cowardice" UCI parameter, instead the opponent one by "Aggressiveness".
294+ // If running in analysis mode, make sure we use symmetrical king safety. We
295+ // do this by replacing both Weights[kingDangerUs] and Weights[kingDangerThem]
296+ // by their average.
298297 if (Options[" UCI_AnalyseMode" ])
299- KingDanger[ 0 ] = KingDanger[ 1 ] = (KingDanger[ 0 ] + KingDanger[ 1 ]) / 2 ;
298+ Weights[KingDangerUs ] = Weights[KingDangerThem ] = (Weights[KingDangerUs ] + Weights[KingDangerThem ]) / 2 ;
300299
301300 const int MaxSlope = 30 ;
302301 const int Peak = 1280 ;
@@ -305,8 +304,8 @@ namespace Eval {
305304 {
306305 t = std::min (Peak, std::min (int (0.4 * i * i), t + MaxSlope));
307306
308- KingDangerTable[0 ][i] = apply_weight (make_score (t, 0 ), make_score (KingDanger[ 0 ], 0 ) );
309- KingDangerTable[1 ][i] = apply_weight (make_score (t, 0 ), make_score (KingDanger[ 1 ], 0 ) );
307+ KingDangerTable[1 ][i] = apply_weight (make_score (t, 0 ), Weights[KingDangerUs] );
308+ KingDangerTable[0 ][i] = apply_weight (make_score (t, 0 ), Weights[KingDangerThem] );
310309 }
311310 }
312311
0 commit comments