// Futility lookup tables (initialized at startup) and their access functions
Value FutilityMargins[16][64]; // [depth][moveNumber]
- int FutilityMoveCounts[32]; // [depth]
+ int FutilityMoveCounts[2][32]; // [improving][depth]
inline Value futility_margin(Depth d, int mn) {
// Init futility move count array
for (d = 0; d < 32; d++)
- FutilityMoveCounts[d] = int(3.001 + 0.3 * pow(double(d), 1.8));
+ {
+ FutilityMoveCounts[1][d] = int(3.001 + 0.3 * pow(double(d), 1.8));
+ FutilityMoveCounts[0][d] = d < 5 ? FutilityMoveCounts[1][d]
+ : 3 * FutilityMoveCounts[1][d] / 4;
+ }
}
void id_loop(Position& pos) {
- Stack stack[MAX_PLY_PLUS_2], *ss = stack+1; // To allow referencing (ss-1)
+ Stack stack[MAX_PLY_PLUS_3], *ss = stack+2; // To allow referencing (ss-2)
int depth, prevBestMoveChanges;
Value bestValue, alpha, beta, delta;
- std::memset(ss-1, 0, 4 * sizeof(Stack));
+ std::memset(ss-2, 0, 5 * sizeof(Stack));
(ss-1)->currentMove = MOVE_NULL; // Hack to skip update gains
depth = BestMoveChanges = 0;
Depth ext, newDepth;
Value bestValue, value, ttValue;
Value eval, nullValue, futilityValue;
- bool inCheck, givesCheck, pvMove, singularExtensionNode;
+ bool inCheck, givesCheck, pvMove, singularExtensionNode, improving;
bool captureOrPromotion, dangerous, doFullDepthSearch;
int moveCount, quietCount;
MovePicker mp(pos, ttMove, depth, History, countermoves, ss);
CheckInfo ci(pos);
value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
+ improving = ss->staticEval >= (ss-2)->staticEval;
singularExtensionNode = !RootNode
&& !SpNode
&& depth >= (PvNode ? 6 * ONE_PLY : 8 * ONE_PLY)
{
// Move count based pruning
if ( depth < 16 * ONE_PLY
- && moveCount >= FutilityMoveCounts[depth]
+ && moveCount >= FutilityMoveCounts[improving][depth]
&& (!threatMove || !refutes(pos, move, threatMove)))
{
if (SpNode)
void RootMove::extract_pv_from_tt(Position& pos) {
- StateInfo state[MAX_PLY_PLUS_2], *st = state;
+ StateInfo state[MAX_PLY_PLUS_3], *st = state;
const TTEntry* tte;
int ply = 0;
Move m = pv[0];
void RootMove::insert_pv_in_tt(Position& pos) {
- StateInfo state[MAX_PLY_PLUS_2], *st = state;
+ StateInfo state[MAX_PLY_PLUS_3], *st = state;
const TTEntry* tte;
int ply = 0;
Threads.mutex.unlock();
- Stack stack[MAX_PLY_PLUS_2], *ss = stack+1; // To allow referencing (ss-1)
+ Stack stack[MAX_PLY_PLUS_3], *ss = stack+2; // To allow referencing (ss-2)
Position pos(*sp->pos, this);
- std::memcpy(ss-1, sp->ss-1, 4 * sizeof(Stack));
+ std::memcpy(ss-2, sp->ss-2, 5 * sizeof(Stack));
ss->splitPoint = sp;
sp->mutex.lock();