Skip to content

Commit

Permalink
Move Tempo to evaluation
Browse files Browse the repository at this point in the history
No functional change.
  • Loading branch information
mcostalba committed Jun 6, 2014
1 parent 69ac45d commit 0875377
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/evaluate.cpp
Expand Up @@ -855,7 +855,7 @@ namespace Eval {
/// of the position always from the point of view of the side to move.

Value evaluate(const Position& pos) {
return do_evaluate<false>(pos);
return do_evaluate<false>(pos) + Tempo;
}


Expand Down
2 changes: 2 additions & 0 deletions src/evaluate.h
Expand Up @@ -26,6 +26,8 @@ class Position;

namespace Eval {

const int Tempo = 17; // Must be visible to search

extern void init();
extern Value evaluate(const Position& pos);
extern std::string trace(const Position& pos);
Expand Down
15 changes: 6 additions & 9 deletions src/search.cpp
Expand Up @@ -76,9 +76,6 @@ namespace {
return (Depth) Reductions[PvNode][i][std::min(int(d) / ONE_PLY, 63)][std::min(mn, 63)];
}

// Tempo bonus. Must be handled by search to preserve eval symmetry.
const int Tempo = 17;

size_t MultiPV, PVIdx;
TimeManager TimeMgr;
double BestMoveChanges;
Expand Down Expand Up @@ -484,7 +481,7 @@ namespace {
{
// Step 2. Check for aborted search and immediate draw
if (Signals.stop || pos.is_draw() || ss->ply > MAX_PLY)
return ss->ply > MAX_PLY && !inCheck ? evaluate(pos) + Tempo : DrawValue[pos.side_to_move()];
return ss->ply > MAX_PLY && !inCheck ? evaluate(pos) : DrawValue[pos.side_to_move()];

// 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
Expand Down Expand Up @@ -539,7 +536,7 @@ namespace {
{
// Never assume anything on values stored in TT
if ((ss->staticEval = eval = tte->eval_value()) == VALUE_NONE)
eval = ss->staticEval = evaluate(pos) + Tempo;
eval = ss->staticEval = evaluate(pos);

// Can ttValue be used as a better position evaluation?
if (ttValue != VALUE_NONE)
Expand All @@ -548,7 +545,7 @@ namespace {
}
else
{
eval = ss->staticEval = ss->nullChild ? -(ss-1)->staticEval + 2 * Tempo : evaluate(pos) + Tempo;
eval = ss->staticEval = ss->nullChild ? -(ss-1)->staticEval + 2 * Eval::Tempo : evaluate(pos);
TT.store(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE, ss->staticEval);
}

Expand Down Expand Up @@ -1066,7 +1063,7 @@ namespace {

// Check for an instant draw or if the maximum ply has been reached
if (pos.is_draw() || ss->ply > MAX_PLY)
return ss->ply > MAX_PLY && !InCheck ? evaluate(pos) + Tempo : DrawValue[pos.side_to_move()];
return ss->ply > MAX_PLY && !InCheck ? evaluate(pos) : DrawValue[pos.side_to_move()];

// 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
Expand Down Expand Up @@ -1103,15 +1100,15 @@ namespace {
{
// Never assume anything on values stored in TT
if ((ss->staticEval = bestValue = tte->eval_value()) == VALUE_NONE)
ss->staticEval = bestValue = evaluate(pos) + Tempo;
ss->staticEval = bestValue = evaluate(pos);

// Can ttValue be used as a better position evaluation?
if (ttValue != VALUE_NONE)
if (tte->bound() & (ttValue > bestValue ? BOUND_LOWER : BOUND_UPPER))
bestValue = ttValue;
}
else
ss->staticEval = bestValue = ss->nullChild ? -(ss-1)->staticEval + 2 * Tempo : evaluate(pos) + Tempo;
ss->staticEval = bestValue = ss->nullChild ? -(ss-1)->staticEval + 2 * Eval::Tempo : evaluate(pos);

// Stand pat. Return immediately if static value is at least beta
if (bestValue >= beta)
Expand Down

0 comments on commit 0875377

Please sign in to comment.