void history_good(int move, const board_t * board, int ThreadId) { unsigned int index; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); ASSERT(!move_is_tactical(move,board)); // if ( move_is_tactical(move,board)) return; // history index = history_index(move,board); HistHit[index]++; HistTot[index]++; if (HistTot[index] >= HistTotMax) { HistHit[index] = (HistHit[index] + 1) / 2; HistTot[index] = (HistTot[index] + 1) / 2; } ASSERT(HistHit[index]<=HistTot[index]); ASSERT(HistTot[index]<HistTotMax); }
static int quiet_move_value(int move, const board_t * board) { int value; int index; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); ASSERT(!MOVE_IS_TACTICAL(move,board)); index = history_index(move,board); value = History[index]; #if DEBUG if (thread_number() > 1) { ASSERT(value<=HistoryValue+8192&&value>=-HistoryValue-8192); } else { ASSERT(value<=HistoryValue&&value>=-HistoryValue); } #endif if (UseMoveEval) { if (value > HistoryScore) value += HistoryEvalMax; value += HISTORY_EVAL(HistEval[index]); } value /= HeightFull; ASSERT(value>=BadScore+100&&value<KillerScore-4); return value; }
static int history_prob(int move, const board_t * board) { int value; int index; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); ASSERT(!MOVE_IS_TACTICAL(move,board)); index = history_index(move,board); #if DEBUG if (thread_number() == 1) { ASSERT(HistHit[index]<=HistTot[index]); ASSERT(HistTot[index]<HistoryMax); } #endif value = (HistHit[index] * 16384) / HistTot[index]; if (value > 16384) value = 16384; // HACK: Thread related ASSERT(value>=0&&value<=16384); return value; }
void good_move(int move, const board_t * board, int depth, int height) { int index; int i; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); ASSERT(depth_is_ok(depth)); ASSERT(height_is_ok(height)); if (move_is_tactical(move,board)) return; // killer if (Killer[height][0] != move) { Killer[height][1] = Killer[height][0]; Killer[height][0] = move; } ASSERT(Killer[height][0]==move); ASSERT(Killer[height][1]!=move); // history index = history_index(move,board); History[index] += HISTORY_INC(depth); if (History[index] >= HistoryMax) { for (i = 0; i < HistorySize; i++) { History[i] = (History[i] + 1) / 2; } } }
bool history_reduction(int move, const board_t * board) { int index; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); // history index = history_index(move,board); if(FailHighStats[index].success > FailHighStats[index].tried / 8) return false; return true; }
void history_success(int move, const board_t * board) { int index; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); if (move_is_tactical(move,board)) return; // history index = history_index(move,board); FailHighStats[index].success++; }
static int quiet_move_value(int move, const board_t * board, int ThreadId) { int value; unsigned int index; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); ASSERT(!move_is_tactical(move,board)); index = history_index(move,board); value = HistoryScore + History[index]; ASSERT(value>=HistoryScore&&value<=KillerScore-4); return value; }
void bad_move(int move, const board_t * board, int depth) { int index; int i; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); ASSERT(depth_is_ok(depth)); if (MOVE_IS_TACTICAL(move,board)) return; // history index = history_index(move,board); History[index] -= HISTORY_INC(depth); if (History[index] < -HistoryValue) { for (i = 0; i < HistorySize; i++) { if (History[i] >= 0) { History[i] = (History[i] + 1) / 2; } else { History[i] = (History[i] - 1) / 2; } } } HistTot[index]++; if (HistTot[index] >= HistoryMax) { HistHit[index] = (HistHit[index] + 1) / 2; HistTot[index] = (HistTot[index] + 1) / 2; } #if DEBUG if (thread_number() == 1) { ASSERT(History[index]<=HistoryValue&&History[index]>=-HistoryValue); ASSERT(HistHit[index]<=HistTot[index]); ASSERT(HistTot[index]<HistoryMax); } else { ASSERT(History[index]<=HistoryValue+8192&&History[index]>=-HistoryValue-8192); } #endif }
static int history_prob(int move, const board_t * board) { int value; int index; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); ASSERT(!move_is_tactical(move,board)); index = history_index(move,board); ASSERT(HistHit[index]<=HistTot[index]); ASSERT(HistTot[index]<HistoryMax); value = (HistHit[index] * 16384) / HistTot[index]; ASSERT(value>=0&&value<=16384); return value; }
void history_bad(int move, const board_t * board) { int index; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); if (move_is_tactical(move,board)) return; // history index = history_index(move,board); HistTot[index]++; if (HistTot[index] >= HistoryMax) { HistHit[index] = (HistHit[index] + 1) / 2; HistTot[index] = (HistTot[index] + 1) / 2; } ASSERT(HistHit[index]<=HistTot[index]); ASSERT(HistTot[index]<HistoryMax); }
void good_move(int move, const board_t * board, int depth, int height, int thread, bool cut) { int index; int i; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); ASSERT(depth_is_ok(depth)); ASSERT(height_is_ok(height)); ASSERT(thread_is_ok(thread)); ASSERT(cut==true||cut==false); if (MOVE_IS_TACTICAL(move,board)) return; // killer if (Killer[thread][height][0] != move) { Killer[thread][height][1] = Killer[thread][height][0]; Killer[thread][height][0] = move; } ASSERT(Killer[thread][height][0]==move); ASSERT(Killer[thread][height][1]!=move); // history index = history_index(move,board); History[index] += HISTORY_INC(depth); if (History[index] > HistoryValue) { for (i = 0; i < HistorySize; i++) { if (History[i] >= 0) { History[i] = (History[i] + 1) / 2; } else { History[i] = (History[i] - 1) / 2; } } } if (cut) { HistHit[index]++; HistTot[index]++; if (HistTot[index] >= HistoryMax) { HistHit[index] = (HistHit[index] + 1) / 2; HistTot[index] = (HistTot[index] + 1) / 2; } #if DEBUG if (thread_number() == 1) { ASSERT(HistHit[index]<=HistTot[index]); ASSERT(HistTot[index]<HistoryMax); } #endif } #if DEBUG if (thread_number() > 1) { ASSERT(History[index]<=HistoryValue+8192&&History[index]>=-HistoryValue-8192); } else { ASSERT(History[index]<=HistoryValue&&History[index]>=-HistoryValue); } #endif }