mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Re-add "Pawn Structure" UCI option
And reshuffle the code to not special case this parameter. No functional change.
This commit is contained in:
parent
eafb66e1aa
commit
7222f47350
5 changed files with 21 additions and 23 deletions
|
@ -19,9 +19,9 @@ Search Log Filename = SearchLog.txt
|
|||
Book File = book.bin
|
||||
Best Book Move = false
|
||||
Contempt Factor = 0
|
||||
Mobility (Middle Game) = 100
|
||||
Mobility (Midgame) = 100
|
||||
Mobility (Endgame) = 100
|
||||
Passed Pawns (Middle Game) = 100
|
||||
Passed Pawns (Midgame) = 100
|
||||
Passed Pawns (Endgame) = 100
|
||||
Space = 100
|
||||
Aggressiveness = 100
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace {
|
|||
const int GrainSize = 4;
|
||||
|
||||
// Evaluation weights, initialized from UCI options
|
||||
enum { Mobility, PassedPawns, Space, KingDangerUs, KingDangerThem };
|
||||
enum { Mobility, PawnStructure, PassedPawns, Space, KingDangerUs, KingDangerThem };
|
||||
Score Weights[6];
|
||||
|
||||
typedef Value V;
|
||||
|
@ -88,7 +88,7 @@ namespace {
|
|||
//
|
||||
// Values modified by Joona Kiiski
|
||||
const Score WeightsInternal[] = {
|
||||
S(289, 344), 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(271, 0), S(307, 0)
|
||||
};
|
||||
|
||||
// MobilityBonus[PieceType][attacked] contains mobility bonuses for middle and
|
||||
|
@ -240,15 +240,16 @@ namespace {
|
|||
template<Color Us, bool Trace>
|
||||
Score evaluate_threats(const Position& pos, EvalInfo& ei);
|
||||
|
||||
template<Color Us>
|
||||
int evaluate_space(const Position& pos, EvalInfo& ei);
|
||||
|
||||
template<Color Us, bool Trace>
|
||||
Score evaluate_passed_pawns(const Position& pos, EvalInfo& ei);
|
||||
|
||||
template<Color Us>
|
||||
int evaluate_space(const Position& pos, EvalInfo& ei);
|
||||
|
||||
Score evaluate_unstoppable_pawns(const Position& pos, EvalInfo& ei);
|
||||
|
||||
Value interpolate(const Score& v, Phase ph, ScaleFactor sf);
|
||||
Score apply_weight(Score v, Score w);
|
||||
Score weight_option(const std::string& mgOpt, const std::string& egOpt, Score internalWeight);
|
||||
double to_cp(Value v);
|
||||
void trace_add(int idx, Score term_w, Score term_b = SCORE_ZERO);
|
||||
|
@ -272,8 +273,9 @@ namespace Eval {
|
|||
|
||||
void init() {
|
||||
|
||||
Weights[Mobility] = weight_option("Mobility (Middle Game)", "Mobility (Endgame)", WeightsInternal[Mobility]);
|
||||
Weights[PassedPawns] = weight_option("Passed Pawns (Middle Game)", "Passed Pawns (Endgame)", WeightsInternal[PassedPawns]);
|
||||
Weights[Mobility] = weight_option("Mobility (Midgame)", "Mobility (Endgame)", WeightsInternal[Mobility]);
|
||||
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[Space] = weight_option("Space", "Space", WeightsInternal[Space]);
|
||||
Weights[KingDangerUs] = weight_option("Cowardice", "Cowardice", WeightsInternal[KingDangerUs]);
|
||||
Weights[KingDangerThem] = weight_option("Aggressiveness", "Aggressiveness", WeightsInternal[KingDangerThem]);
|
||||
|
@ -374,7 +376,7 @@ Value do_evaluate(const Position& pos, Value& margin) {
|
|||
|
||||
// Probe the pawn hash table
|
||||
ei.pi = Pawns::probe(pos, th->pawnsTable);
|
||||
score += ei.pi->pawns_value();
|
||||
score += apply_weight(ei.pi->pawns_value(), Weights[PawnStructure]);
|
||||
|
||||
// Initialize attack and king safety bitboards
|
||||
init_eval_info<WHITE>(pos, ei);
|
||||
|
@ -1119,6 +1121,11 @@ Value do_evaluate(const Position& pos, Value& margin) {
|
|||
return Value((result + GrainSize / 2) & ~(GrainSize - 1));
|
||||
}
|
||||
|
||||
// apply_weight() weights score v by score w trying to prevent overflow
|
||||
Score apply_weight(Score v, Score w) {
|
||||
return make_score((int(mg_value(v)) * mg_value(w)) / 0x100,
|
||||
(int(eg_value(v)) * eg_value(w)) / 0x100);
|
||||
}
|
||||
|
||||
// weight_option() computes the value of an evaluation weight, by combining
|
||||
// two UCI-configurable weights (midgame and endgame) with an internal weight.
|
||||
|
|
|
@ -62,8 +62,6 @@ namespace {
|
|||
S(34,68), S(83,166), S(0, 0), S( 0, 0)
|
||||
};
|
||||
|
||||
const Score PawnStructureWeight = S(233, 201);
|
||||
|
||||
// Weakness of our pawn shelter in front of the king indexed by [king pawn][rank]
|
||||
const Value ShelterWeakness[2][RANK_NB] =
|
||||
{ { V(141), V(0), V(38), V(102), V(128), V(141), V(141) },
|
||||
|
@ -215,9 +213,6 @@ Entry* probe(const Position& pos, Table& entries) {
|
|||
|
||||
e->value = evaluate_pawns<WHITE>(pos, wPawns, bPawns, e)
|
||||
- evaluate_pawns<BLACK>(pos, bPawns, wPawns, e);
|
||||
|
||||
e->value = apply_weight(e->value, PawnStructureWeight);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
|
|
|
@ -325,12 +325,6 @@ inline Score operator/(Score s, int i) {
|
|||
return make_score(mg_value(s) / i, eg_value(s) / i);
|
||||
}
|
||||
|
||||
/// Weight score v by score w trying to prevent overflow
|
||||
inline Score apply_weight(Score v, Score w) {
|
||||
return make_score((int(mg_value(v)) * mg_value(w)) / 0x100,
|
||||
(int(eg_value(v)) * eg_value(w)) / 0x100);
|
||||
}
|
||||
|
||||
#undef ENABLE_OPERATORS_ON
|
||||
#undef ENABLE_SAFE_OPERATORS_ON
|
||||
|
||||
|
|
|
@ -65,9 +65,11 @@ void init(OptionsMap& o) {
|
|||
o["Book File"] = Option("book.bin");
|
||||
o["Best Book Move"] = Option(false);
|
||||
o["Contempt Factor"] = Option(0, -50, 50);
|
||||
o["Mobility (Middle Game)"] = Option(100, 0, 200, on_eval);
|
||||
o["Mobility (Midgame)"] = Option(100, 0, 200, on_eval);
|
||||
o["Mobility (Endgame)"] = Option(100, 0, 200, on_eval);
|
||||
o["Passed Pawns (Middle Game)"] = Option(100, 0, 200, on_eval);
|
||||
o["Pawn Structure (Midgame)"] = Option(100, 0, 200, on_eval);
|
||||
o["Pawn Structure (Endgame)"] = 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["Space"] = Option(100, 0, 200, on_eval);
|
||||
o["Aggressiveness"] = Option(100, 0, 200, on_eval);
|
||||
|
|
Loading…
Add table
Reference in a new issue