Skip to content

Commit

Permalink
Make contempt dependent on current score and reduce default contempt …
Browse files Browse the repository at this point in the history
…by 10%.

Bench: 5712242
  • Loading branch information
Stefano80 committed Feb 5, 2018
1 parent 414a3e6 commit cee1828
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,6 @@ void MainThread::search() {
Time.init(Limits, us, rootPos.game_ply());
TT.new_search();

int contempt = Options["Contempt"] * PawnValueEg / 100; // From centipawns

Eval::Contempt = (us == WHITE ? make_score(contempt, contempt / 2)
: -make_score(contempt, contempt / 2));

if (rootMoves.empty())
{
rootMoves.emplace_back(MOVE_NONE);
Expand Down Expand Up @@ -307,6 +302,10 @@ void Thread::search() {

multiPV = std::min(multiPV, rootMoves.size());

int contempt = Options["Contempt"] * PawnValueEg / 100; // From centipawns
Eval::Contempt = (rootPos.side_to_move() == WHITE ? make_score(contempt, contempt / 2)
: -make_score(contempt, contempt / 2));

// Iterative deepening loop until requested to stop or the target depth is reached
while ( (rootDepth += ONE_PLY) < DEPTH_MAX
&& !Threads.stop
Expand Down Expand Up @@ -341,6 +340,12 @@ void Thread::search() {
delta = Value(18);
alpha = std::max(rootMoves[PVIdx].previousScore - delta,-VALUE_INFINITE);
beta = std::min(rootMoves[PVIdx].previousScore + delta, VALUE_INFINITE);

// Adjust contempt based on current situation
contempt = Options["Contempt"] * PawnValueEg / 100 + bestValue/10; // From centipawns
Eval::Contempt = (rootPos.side_to_move() == WHITE ? make_score(contempt, contempt / 2)
: -make_score(contempt, contempt / 2));

}

// Start with a small aspiration window and, in the case of a fail
Expand Down
2 changes: 1 addition & 1 deletion src/ucioption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void init(OptionsMap& o) {
const int MaxHashMB = Is64Bit ? 131072 : 2048;

o["Debug Log File"] << Option("", on_logger);
o["Contempt"] << Option(20, -100, 100);
o["Contempt"] << Option(18, -100, 100);
o["Threads"] << Option(1, 1, 512, on_threads);
o["Hash"] << Option(16, 1, MaxHashMB, on_hash_size);
o["Clear Hash"] << Option(on_clear_hash);
Expand Down

0 comments on commit cee1828

Please sign in to comment.