Depth ThreatDepth;
// Depth limit for selective search
- Depth SelectiveDepth;
+ const Depth SelectiveDepth = 7*OnePly;
// Use internal iterative deepening?
const bool UseIIDAtPVNodes = true;
// and near frontier nodes
const Value FutilityMarginQS = Value(0x80);
- //remaining depth: 1 ply 1.5 ply 2 ply 2.5 ply 3 ply 3.5 ply
- const Value FutilityMargins[12] = { Value(0x100), Value(0x120), Value(0x200), Value(0x220), Value(0x250), Value(0x270),
- // 4 ply 4.5 ply 5 ply 5.5 ply 6 ply 6.5 ply
- Value(0x2A0), Value(0x2C0), Value(0x340), Value(0x360), Value(0x3A0), Value(0x3C0)};
+ // Remaining depth: 1 ply 1.5 ply 2 ply 2.5 ply 3 ply 3.5 ply
+ const Value FutilityMargins[12] = { Value(0x100), Value(0x120), Value(0x200), Value(0x220), Value(0x250), Value(0x270),
+ // 4 ply 4.5 ply 5 ply 5.5 ply 6 ply 6.5 ply
+ Value(0x2A0), Value(0x2C0), Value(0x340), Value(0x360), Value(0x3A0), Value(0x3C0) };
+ // Razoring
+ const Depth RazorDepth = 4*OnePly;
- // Razoring
- const Depth RazorDepth = 4*OnePly;
+ // Remaining depth: 1 ply 1.5 ply 2 ply 2.5 ply 3 ply 3.5 ply
+ const Value RazorMargins[6] = { Value(0x180), Value(0x300), Value(0x300), Value(0x3C0), Value(0x3C0), Value(0x3C0) };
- //remaining depth: 1 ply 1.5 ply 2 ply 2.5 ply 3 ply 3.5 ply
- const Value RazorMargins[6] = { Value(0x180), Value(0x300), Value(0x300), Value(0x3C0), Value(0x3C0), Value(0x3C0) };
-
- //remaining depth: 1 ply 1.5 ply 2 ply 2.5 ply 3 ply 3.5 ply
- const Value RazorApprMargins[6] = { Value(0x100000), Value(0x300), Value(0x300), Value(0x300), Value(0x300), Value(0x300) };
+ // Remaining depth: 1 ply 1.5 ply 2 ply 2.5 ply 3 ply 3.5 ply
+ const Value RazorApprMargins[6] = { Value(0x520), Value(0x300), Value(0x300), Value(0x300), Value(0x300), Value(0x300) };
// Last seconds noise filtering (LSN)
bool UseLSNFiltering;
////
// The main transposition table
-TranspositionTable TT = TranspositionTable(TTDefaultSize);
+TranspositionTable TT;
// Number of active threads:
LMRPVMoves = get_option_value_int("Full Depth Moves (PV nodes)") + 1;
LMRNonPVMoves = get_option_value_int("Full Depth Moves (non-PV nodes)") + 1;
ThreatDepth = get_option_value_int("Threat Depth") * OnePly;
- SelectiveDepth = get_option_value_int("Selective Plies") * OnePly;
Chess960 = get_option_value_bool("UCI_Chess960");
ShowCurrentLine = get_option_value_bool("UCI_ShowCurrLine");
UseQSearchFutilityPruning = get_option_value_bool("Futility Pruning (Quiescence Search)");
UseFutilityPruning = get_option_value_bool("Futility Pruning (Main Search)");
- //FutilityMarginQS = value_from_centipawns(get_option_value_int("Futility Margin (Quiescence Search)"));
- //int fmScale = get_option_value_int("Futility Margin Scale Factor (Main Search)");
- //for (int i = 0; i < 6; i++)
- // FutilityMargins[i] = (FutilityMargins[i] * fmScale) / 100;
-
- //RazorDepth = (get_option_value_int("Maximum Razoring Depth") + 1) * OnePly;
- //RazorMargin = value_from_centipawns(get_option_value_int("Razoring Margin"));
-
UseLSNFiltering = get_option_value_bool("LSN filtering");
LSNTime = get_option_value_int("LSN Time Margin (sec)") * 1000;
LSNValue = value_from_centipawns(get_option_value_int("LSN Value Margin"));
// Transposition table lookup. At PV nodes, we don't use the TT for
// pruning, but only for move ordering.
- const TTEntry* tte = TT.retrieve(pos);
+ const TTEntry* tte = TT.retrieve(pos.get_key());
Move ttMove = (tte ? tte->move() : MOVE_NONE);
// Go with internal iterative deepening if we don't have a TT move
return bestValue;
if (bestValue <= oldAlpha)
- TT.store(pos, value_to_tt(bestValue, ply), depth, MOVE_NONE, VALUE_TYPE_UPPER);
+ TT.store(pos.get_key(), value_to_tt(bestValue, ply), VALUE_TYPE_UPPER, depth, MOVE_NONE);
else if (bestValue >= beta)
{
update_history(pos, m, depth, movesSearched, moveCount);
update_killers(m, ss[ply]);
}
- TT.store(pos, value_to_tt(bestValue, ply), depth, m, VALUE_TYPE_LOWER);
+ TT.store(pos.get_key(), value_to_tt(bestValue, ply), VALUE_TYPE_LOWER, depth, m);
}
else
- TT.store(pos, value_to_tt(bestValue, ply), depth, ss[ply].pv[ply], VALUE_TYPE_EXACT);
+ TT.store(pos.get_key(), value_to_tt(bestValue, ply), VALUE_TYPE_EXACT, depth, ss[ply].pv[ply]);
return bestValue;
}
return beta - 1;
// Transposition table lookup
- const TTEntry* tte = TT.retrieve(pos);
+ const TTEntry* tte = TT.retrieve(pos.get_key());
Move ttMove = (tte ? tte->move() : MOVE_NONE);
if (tte && ok_to_use_TT(tte, depth, beta, ply))
else if ( !value_is_mate(beta)
&& depth < RazorDepth
&& approximateEval < beta - RazorApprMargins[int(depth) - 2]
+ && ss[ply - 1].currentMove != MOVE_NULL
&& ttMove == MOVE_NONE
&& !pos.has_pawn_on_7th(pos.side_to_move()))
{
continue;
// Value based pruning
- if (depth < 7 * OnePly && approximateEval < beta)
+ if (approximateEval < beta)
{
if (futilityValue == VALUE_NONE)
futilityValue = evaluate(pos, ei, threadID)
return bestValue;
if (bestValue < beta)
- TT.store(pos, value_to_tt(bestValue, ply), depth, MOVE_NONE, VALUE_TYPE_UPPER);
+ TT.store(pos.get_key(), value_to_tt(bestValue, ply), VALUE_TYPE_UPPER, depth, MOVE_NONE);
else
{
BetaCounter.add(pos.side_to_move(), depth, threadID);
update_history(pos, m, depth, movesSearched, moveCount);
update_killers(m, ss[ply]);
}
- TT.store(pos, value_to_tt(bestValue, ply), depth, m, VALUE_TYPE_LOWER);
+ TT.store(pos.get_key(), value_to_tt(bestValue, ply), VALUE_TYPE_LOWER, depth, m);
}
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
bool pvNode = (beta - alpha != 1);
if (!pvNode)
{
- tte = TT.retrieve(pos);
+ tte = TT.retrieve(pos.get_key());
if (tte && ok_to_use_TT(tte, depth, beta, ply))
{
assert(tte->type() != VALUE_TYPE_EVAL);
{
// Store the score to avoid a future costly evaluation() call
if (!isCheck && !tte && ei.futilityMargin == 0)
- TT.store(pos, value_to_tt(bestValue, ply), Depth(-127*OnePly), MOVE_NONE, VALUE_TYPE_EVAL);
+ TT.store(pos.get_key(), value_to_tt(bestValue, ply), VALUE_TYPE_EVAL, Depth(-127*OnePly), MOVE_NONE);
return bestValue;
}
{
Depth d = (depth == Depth(0) ? Depth(0) : Depth(-1));
if (bestValue < beta)
- TT.store(pos, value_to_tt(bestValue, ply), d, MOVE_NONE, VALUE_TYPE_UPPER);
+ TT.store(pos.get_key(), value_to_tt(bestValue, ply), VALUE_TYPE_UPPER, d, MOVE_NONE);
else
- TT.store(pos, value_to_tt(bestValue, ply), d, m, VALUE_TYPE_LOWER);
+ TT.store(pos.get_key(), value_to_tt(bestValue, ply), VALUE_TYPE_LOWER, d, m);
}
// Update killers only for good check moves
// Constructor
RootMove::RootMove() {
- nodes = cumulativeNodes = 0ULL;
+ nodes = cumulativeNodes = ourBeta = theirBeta = 0ULL;
}
// RootMove::operator<() is the comparison function used when
for (int k = 0; !includeMove && searchMoves[k] != MOVE_NONE; k++)
includeMove = (searchMoves[k] == mlist[i].move);
- if (includeMove)
- {
- // Find a quick score for the move
- StateInfo st;
- SearchStack ss[PLY_MAX_PLUS_2];
-
- moves[count].move = mlist[i].move;
- moves[count].nodes = 0ULL;
- pos.do_move(moves[count].move, st);
- moves[count].score = -qsearch(pos, ss, -VALUE_INFINITE, VALUE_INFINITE,
- Depth(0), 1, 0);
- pos.undo_move(moves[count].move);
- moves[count].pv[0] = moves[i].move;
- moves[count].pv[1] = MOVE_NONE; // FIXME
- count++;
- }
+ if (!includeMove)
+ continue;
+
+ // Find a quick score for the move
+ StateInfo st;
+ SearchStack ss[PLY_MAX_PLUS_2];
+
+ moves[count].move = mlist[i].move;
+ pos.do_move(moves[count].move, st);
+ moves[count].score = -qsearch(pos, ss, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 1, 0);
+ pos.undo_move(moves[count].move);
+ moves[count].pv[0] = moves[count].move;
+ moves[count].pv[1] = MOVE_NONE; // FIXME
+ count++;
}
sort();
}