This is very crude and very basic: simply in case
of a draw for repetition or 50 moves rule return
a negative score instead of zero according to the
contempt factor (in centipawns). If contempt is
positive engine will try to avoid draws (to use
with weaker opponents), if negative engine will
try to draw. If zero (default) there are no changes.
No functional change.
namespace Eval {
Color RootColor;
namespace Eval {
Color RootColor;
+ Value ValueDrawContempt;
/// evaluate() is the main evaluation function. It always computes two
/// values, an endgame score and a middle game score, and interpolates
/// evaluate() is the main evaluation function. It always computes two
/// values, an endgame score and a middle game score, and interpolates
KingDangerTable[1][i] = apply_weight(make_score(t, 0), Weights[KingDangerUs]);
KingDangerTable[0][i] = apply_weight(make_score(t, 0), Weights[KingDangerThem]);
}
KingDangerTable[1][i] = apply_weight(make_score(t, 0), Weights[KingDangerUs]);
KingDangerTable[0][i] = apply_weight(make_score(t, 0), Weights[KingDangerThem]);
}
+
+ ValueDrawContempt = VALUE_DRAW - Options["Contempt Factor"] * PawnValueMg / 100;
namespace Eval {
extern Color RootColor;
namespace Eval {
extern Color RootColor;
+extern Value ValueDrawContempt;
extern void init();
extern Value evaluate(const Position& pos, Value& margin);
extern void init();
extern Value evaluate(const Position& pos, Value& margin);
{
// Step 2. Check for aborted search and immediate draw
if (Signals.stop || pos.is_draw<false>() || ss->ply > MAX_PLY)
{
// Step 2. Check for aborted search and immediate draw
if (Signals.stop || pos.is_draw<false>() || ss->ply > MAX_PLY)
+ return Eval::ValueDrawContempt;
// Step 3. Mate distance pruning. Even if we mate at the next move our score
// would be at best mate_in(ss->ply+1), but if alpha is already bigger because
// Step 3. Mate distance pruning. Even if we mate at the next move our score
// would be at best mate_in(ss->ply+1), but if alpha is already bigger because
// Check for an instant draw or maximum ply reached
if (pos.is_draw<true>() || ss->ply > MAX_PLY)
// Check for an instant draw or maximum ply reached
if (pos.is_draw<true>() || ss->ply > MAX_PLY)
+ return Eval::ValueDrawContempt;
// Decide whether or not to include checks, this fixes also the type of
// TT entry depth that we are going to use. Note that in qsearch we use
// Decide whether or not to include checks, this fixes also the type of
// TT entry depth that we are going to use. Note that in qsearch we use
o["Search Log Filename"] = Option("SearchLog.txt");
o["Book File"] = Option("book.bin");
o["Best Book Move"] = Option(false);
o["Search Log Filename"] = Option("SearchLog.txt");
o["Book File"] = Option("book.bin");
o["Best Book Move"] = Option(false);
+ o["Contempt Factor"] = Option(0, -50, 50, on_eval);
o["Mobility (Middle Game)"] = 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["Mobility (Middle Game)"] = 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);