else if (Type == QUIETS)
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
- + 2 * (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
- + 2 * (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
- + 2 * (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
- + (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)]
+ + 2 * (*continuationHistory[0])[history_slot(pos.moved_piece(m))][to_sq(m)]
+ + 2 * (*continuationHistory[1])[history_slot(pos.moved_piece(m))][to_sq(m)]
+ + 2 * (*continuationHistory[3])[history_slot(pos.moved_piece(m))][to_sq(m)]
- + (*continuationHistory[5])[history_slot(pos.moved_piece(m))][to_sq(m)];
++ + (*continuationHistory[5])[history_slot(pos.moved_piece(m))][to_sq(m)]
+ + (ply < MAX_LPH ? 4 * (*lowPlyHistory)[ply][from_to(m)] : 0);
else // Type == EVASIONS
{
/// unsuccessful during the current search, and is used for reduction and move
/// ordering decisions. It uses 2 tables (one for each color) indexed by
/// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards
-typedef Stats<int16_t, 10692, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)> ButterflyHistory;
+typedef Stats<int16_t, 10692, COLOR_NB, int(SQUARE_NB + 1) * int(1 << SQUARE_BITS)> ButterflyHistory;
+ /// LowPlyHistory at higher depths records successful quiet moves on plies 0 to 3
+ /// and quiet moves which are/were in the PV (ttPv)
+ /// It get cleared with each new search and get filled during iterative deepening
+ constexpr int MAX_LPH = 4;
-typedef Stats<int16_t, 10692, MAX_LPH, int(SQUARE_NB) * int(SQUARE_NB)> LowPlyHistory;
++typedef Stats<int16_t, 10692, MAX_LPH, int(SQUARE_NB + 1) * int(1 << SQUARE_BITS)> LowPlyHistory;
+
/// CounterMoveHistory stores counter moves indexed by [piece][to] of the previous
/// move, see www.chessprogramming.org/Countermove_Heuristic
typedef Stats<Move, NOT_USED, PIECE_NB, SQUARE_NB> CounterMoveHistory;
th->nodes = th->tbHits = th->nmpMinPly = 0;
th->rootDepth = th->completedDepth = 0;
th->rootMoves = rootMoves;
- th->rootPos.set(pos.fen(), pos.is_chess960(), &setupStates->back(), th);
+ th->rootPos.set(pos.variant(), pos.fen(), pos.is_chess960(), &setupStates->back(), th);
+ th->lowPlyHistory.fill(0);
}
setupStates->back() = tmp;