Skip to content

Commit d3fe153

Browse files
committed
Re-add 'Cowardice' and 'Aggressiveness' UCI options
I have lost my bet with Jean-Paul, so now I re-add the two options...and I am glad of it :-) No functional change.
1 parent 8899220 commit d3fe153

3 files changed

Lines changed: 21 additions & 18 deletions

File tree

polyglot.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Mobility (Endgame) = 100
2424
Passed Pawns (Middle Game) = 100
2525
Passed Pawns (Endgame) = 100
2626
Space = 100
27+
Aggressiveness = 100
28+
Cowardice = 100
2729
Min Split Depth = 4
2830
Max Threads per Split Point = 5
2931
Threads = 1

src/evaluate.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/ucioption.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ void init(OptionsMap& o) {
7070
o["Passed Pawns (Middle Game)"] = Option(100, 0, 200, on_eval);
7171
o["Passed Pawns (Endgame)"] = Option(100, 0, 200, on_eval);
7272
o["Space"] = Option(100, 0, 200, on_eval);
73+
o["Aggressiveness"] = Option(100, 0, 200, on_eval);
74+
o["Cowardice"] = Option(100, 0, 200, on_eval);
7375
o["Min Split Depth"] = Option(msd, 4, 12, on_threads);
7476
o["Max Threads per Split Point"] = Option(5, 4, 8, on_threads);
7577
o["Threads"] = Option(cpus, 1, MAX_THREADS, on_threads);

0 commit comments

Comments
 (0)