mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Symmetric king safety
Retire current asymmetric king evaluation and use a much simpler symmetric one. As a side effect retire the infamous 'Aggressiveness' and 'Cowardice' UCI options. Tested in no-regression mode, Passed both STC LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 33855 W: 5863 L: 5764 D: 22228 And LTC LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 40571 W: 5852 L: 5760 D: 28959 bench: 8321835
This commit is contained in:
parent
5e03734eac
commit
40f5abba10
5 changed files with 16 additions and 27 deletions
|
@ -90,8 +90,8 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Evaluation weights, initialized from UCI options
|
// Evaluation weights, initialized from UCI options
|
||||||
enum { Mobility, PawnStructure, PassedPawns, Space, KingDangerUs, KingDangerThem };
|
enum { Mobility, PawnStructure, PassedPawns, Space, KingSafety };
|
||||||
struct Weight { int mg, eg; } Weights[6];
|
struct Weight { int mg, eg; } Weights[5];
|
||||||
|
|
||||||
typedef Value V;
|
typedef Value V;
|
||||||
#define S(mg, eg) make_score(mg, eg)
|
#define S(mg, eg) make_score(mg, eg)
|
||||||
|
@ -103,7 +103,7 @@ namespace {
|
||||||
//
|
//
|
||||||
// Values modified by Joona Kiiski
|
// Values modified by Joona Kiiski
|
||||||
const Score WeightsInternal[] = {
|
const Score WeightsInternal[] = {
|
||||||
S(289, 344), S(233, 201), S(221, 273), S(46, 0), S(271, 0), S(307, 0)
|
S(289, 344), S(233, 201), S(221, 273), S(46, 0), S(289, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
// MobilityBonus[PieceType][attacked] contains bonuses for middle and end
|
// MobilityBonus[PieceType][attacked] contains bonuses for middle and end
|
||||||
|
@ -202,9 +202,9 @@ namespace {
|
||||||
const int BishopCheck = 2;
|
const int BishopCheck = 2;
|
||||||
const int KnightCheck = 3;
|
const int KnightCheck = 3;
|
||||||
|
|
||||||
// KingDanger[Color][attackUnits] contains the actual king danger weighted
|
// KingDanger[attackUnits] contains the actual king danger weighted
|
||||||
// scores, indexed by color and by a calculated integer number.
|
// scores, indexed by a calculated integer number.
|
||||||
Score KingDanger[COLOR_NB][128];
|
Score KingDanger[128];
|
||||||
|
|
||||||
|
|
||||||
// apply_weight() weighs score 'v' by weight 'w' trying to prevent overflow
|
// apply_weight() weighs score 'v' by weight 'w' trying to prevent overflow
|
||||||
|
@ -501,7 +501,7 @@ namespace {
|
||||||
|
|
||||||
// Finally, extract the king danger score from the KingDanger[]
|
// Finally, extract the king danger score from the KingDanger[]
|
||||||
// array and subtract the score from evaluation.
|
// array and subtract the score from evaluation.
|
||||||
score -= KingDanger[Us == Search::RootColor][attackUnits];
|
score -= KingDanger[attackUnits];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Trace)
|
if (Trace)
|
||||||
|
@ -902,8 +902,7 @@ namespace Eval {
|
||||||
Weights[PawnStructure] = weight_option("Pawn Structure (Midgame)", "Pawn Structure (Endgame)", WeightsInternal[PawnStructure]);
|
Weights[PawnStructure] = weight_option("Pawn Structure (Midgame)", "Pawn Structure (Endgame)", WeightsInternal[PawnStructure]);
|
||||||
Weights[PassedPawns] = weight_option("Passed Pawns (Midgame)", "Passed Pawns (Endgame)", WeightsInternal[PassedPawns]);
|
Weights[PassedPawns] = weight_option("Passed Pawns (Midgame)", "Passed Pawns (Endgame)", WeightsInternal[PassedPawns]);
|
||||||
Weights[Space] = weight_option("Space", "Space", WeightsInternal[Space]);
|
Weights[Space] = weight_option("Space", "Space", WeightsInternal[Space]);
|
||||||
Weights[KingDangerUs] = weight_option("Cowardice", "Cowardice", WeightsInternal[KingDangerUs]);
|
Weights[KingSafety] = weight_option("King Safety", "King Safety", WeightsInternal[KingSafety]);
|
||||||
Weights[KingDangerThem] = weight_option("Aggressiveness", "Aggressiveness", WeightsInternal[KingDangerThem]);
|
|
||||||
|
|
||||||
const double MaxSlope = 30;
|
const double MaxSlope = 30;
|
||||||
const double Peak = 1280;
|
const double Peak = 1280;
|
||||||
|
@ -911,9 +910,7 @@ namespace Eval {
|
||||||
for (int t = 0, i = 1; i < 100; ++i)
|
for (int t = 0, i = 1; i < 100; ++i)
|
||||||
{
|
{
|
||||||
t = int(std::min(Peak, std::min(0.4 * i * i, t + MaxSlope)));
|
t = int(std::min(Peak, std::min(0.4 * i * i, t + MaxSlope)));
|
||||||
|
KingDanger[i] = apply_weight(make_score(t, 0), Weights[KingSafety]);
|
||||||
KingDanger[1][i] = apply_weight(make_score(t, 0), Weights[KingDangerUs]);
|
|
||||||
KingDanger[0][i] = apply_weight(make_score(t, 0), Weights[KingDangerThem]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ namespace Search {
|
||||||
LimitsType Limits;
|
LimitsType Limits;
|
||||||
std::vector<RootMove> RootMoves;
|
std::vector<RootMove> RootMoves;
|
||||||
Position RootPos;
|
Position RootPos;
|
||||||
Color RootColor;
|
|
||||||
Time::point SearchTime;
|
Time::point SearchTime;
|
||||||
StateStackPtr SetupStates;
|
StateStackPtr SetupStates;
|
||||||
}
|
}
|
||||||
|
@ -182,12 +181,11 @@ void Search::think() {
|
||||||
|
|
||||||
static PolyglotBook book; // Defined static to initialize the PRNG only once
|
static PolyglotBook book; // Defined static to initialize the PRNG only once
|
||||||
|
|
||||||
RootColor = RootPos.side_to_move();
|
TimeMgr.init(Limits, RootPos.game_ply(), RootPos.side_to_move());
|
||||||
TimeMgr.init(Limits, RootPos.game_ply(), RootColor);
|
|
||||||
|
|
||||||
int cf = Options["Contempt Factor"] * PawnValueEg / 100; // From centipawns
|
int cf = Options["Contempt Factor"] * PawnValueEg / 100; // From centipawns
|
||||||
DrawValue[ RootColor] = VALUE_DRAW - Value(cf);
|
DrawValue[ RootPos.side_to_move()] = VALUE_DRAW - Value(cf);
|
||||||
DrawValue[~RootColor] = VALUE_DRAW + Value(cf);
|
DrawValue[~RootPos.side_to_move()] = VALUE_DRAW + Value(cf);
|
||||||
|
|
||||||
if (RootMoves.empty())
|
if (RootMoves.empty())
|
||||||
{
|
{
|
||||||
|
@ -216,8 +214,8 @@ void Search::think() {
|
||||||
log << "\nSearching: " << RootPos.fen()
|
log << "\nSearching: " << RootPos.fen()
|
||||||
<< "\ninfinite: " << Limits.infinite
|
<< "\ninfinite: " << Limits.infinite
|
||||||
<< " ponder: " << Limits.ponder
|
<< " ponder: " << Limits.ponder
|
||||||
<< " time: " << Limits.time[RootColor]
|
<< " time: " << Limits.time[RootPos.side_to_move()]
|
||||||
<< " increment: " << Limits.inc[RootColor]
|
<< " increment: " << Limits.inc[RootPos.side_to_move()]
|
||||||
<< " moves to go: " << Limits.movestogo
|
<< " moves to go: " << Limits.movestogo
|
||||||
<< "\n" << std::endl;
|
<< "\n" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,6 @@ extern volatile SignalsType Signals;
|
||||||
extern LimitsType Limits;
|
extern LimitsType Limits;
|
||||||
extern std::vector<RootMove> RootMoves;
|
extern std::vector<RootMove> RootMoves;
|
||||||
extern Position RootPos;
|
extern Position RootPos;
|
||||||
extern Color RootColor;
|
|
||||||
extern Time::point SearchTime;
|
extern Time::point SearchTime;
|
||||||
extern StateStackPtr SetupStates;
|
extern StateStackPtr SetupStates;
|
||||||
|
|
||||||
|
|
|
@ -195,11 +195,6 @@ void UCI::loop(int argc, char* argv[]) {
|
||||||
<< "\n" << Options
|
<< "\n" << Options
|
||||||
<< "\nuciok" << sync_endl;
|
<< "\nuciok" << sync_endl;
|
||||||
|
|
||||||
else if (token == "eval")
|
|
||||||
{
|
|
||||||
Search::RootColor = pos.side_to_move(); // Ensure it is set
|
|
||||||
sync_cout << Eval::trace(pos) << sync_endl;
|
|
||||||
}
|
|
||||||
else if (token == "ucinewgame") TT.clear();
|
else if (token == "ucinewgame") TT.clear();
|
||||||
else if (token == "go") go(pos, is);
|
else if (token == "go") go(pos, is);
|
||||||
else if (token == "position") position(pos, is);
|
else if (token == "position") position(pos, is);
|
||||||
|
@ -207,6 +202,7 @@ void UCI::loop(int argc, char* argv[]) {
|
||||||
else if (token == "flip") pos.flip();
|
else if (token == "flip") pos.flip();
|
||||||
else if (token == "bench") benchmark(pos, is);
|
else if (token == "bench") benchmark(pos, is);
|
||||||
else if (token == "d") sync_cout << pos.pretty() << sync_endl;
|
else if (token == "d") sync_cout << pos.pretty() << sync_endl;
|
||||||
|
else if (token == "eval") sync_cout << Eval::trace(pos) << sync_endl;
|
||||||
else if (token == "isready") sync_cout << "readyok" << sync_endl;
|
else if (token == "isready") sync_cout << "readyok" << sync_endl;
|
||||||
else
|
else
|
||||||
sync_cout << "Unknown command: " << cmd << sync_endl;
|
sync_cout << "Unknown command: " << cmd << sync_endl;
|
||||||
|
|
|
@ -67,8 +67,7 @@ void init(OptionsMap& o) {
|
||||||
o["Passed Pawns (Midgame)"] << Option(100, 0, 200, on_eval);
|
o["Passed Pawns (Midgame)"] << Option(100, 0, 200, on_eval);
|
||||||
o["Passed Pawns (Endgame)"] << Option(100, 0, 200, on_eval);
|
o["Passed Pawns (Endgame)"] << Option(100, 0, 200, on_eval);
|
||||||
o["Space"] << Option(100, 0, 200, on_eval);
|
o["Space"] << Option(100, 0, 200, on_eval);
|
||||||
o["Aggressiveness"] << Option(100, 0, 200, on_eval);
|
o["King Safety"] << Option(100, 0, 200, on_eval);
|
||||||
o["Cowardice"] << Option(100, 0, 200, on_eval);
|
|
||||||
o["Min Split Depth"] << Option(0, 0, 12, on_threads);
|
o["Min Split Depth"] << Option(0, 0, 12, on_threads);
|
||||||
o["Threads"] << Option(1, 1, MAX_THREADS, on_threads);
|
o["Threads"] << Option(1, 1, MAX_THREADS, on_threads);
|
||||||
o["Hash"] << Option(32, 1, 16384, on_hash_size);
|
o["Hash"] << Option(32, 1, 16384, on_hash_size);
|
||||||
|
|
Loading…
Add table
Reference in a new issue