Skip to content

Commit

Permalink
2 ply conthist
Browse files Browse the repository at this point in the history
Bench: 9923161
  • Loading branch information
SzilBalazs committed Sep 3, 2023
1 parent 31b720e commit ff38160
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/search/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ namespace search {

if ((ss - 1)->move.is_ok()) {
update_counter_moves(move, (ss - 1)->move);
update_history(conthist[(ss - 1)->pt][(ss - 1)->move.get_to()][move.get_from()][move.get_to()], depth * 100);
update_history(get_conthist_ref<1>(move, ss), depth * 100);
}

if ((ss - 2)->move.is_ok()) {
update_history(get_conthist_ref<2>(move, ss), depth * 100);
}
}

Expand All @@ -64,15 +68,25 @@ namespace search {
update_history(butterfly[move.get_from()][move.get_to()], -depth * 100);

if ((ss - 1)->move.is_ok()) {
update_history(conthist[(ss - 1)->pt][(ss - 1)->move.get_to()][move.get_from()][move.get_to()], -depth * 100);
update_history(get_conthist_ref<1>(move, ss), -depth * 100);
}

if ((ss - 2)->move.is_ok()) {
update_history(get_conthist_ref<2>(move, ss), -depth * 100);
}
}

Score get_history(chess::Move move, SearchStack *ss) const {
Score value = butterfly[move.get_from()][move.get_to()];

if ((ss - 1)->move.is_ok()) {
value += 2 * conthist[(ss - 1)->pt][(ss - 1)->move.get_to()][move.get_from()][move.get_to()];
value += 2 * get_conthist<1>(move, ss);
}

if ((ss - 2)->move.is_ok()) {
value += get_conthist<2>(move, ss);
}

return value;
}

Expand Down Expand Up @@ -107,6 +121,16 @@ namespace search {
counter_moves[last_move.get_from()][last_move.get_to()] = move;
}

template<Ply ply>
Score get_conthist(const chess::Move &move, SearchStack *ss) const {
return conthist[(ss - ply)->pt][(ss - ply)->move.get_to()][move.get_from()][move.get_to()];
}

template<Ply ply>
Score &get_conthist_ref(const chess::Move &move, SearchStack *ss) {
return conthist[(ss - ply)->pt][(ss - ply)->move.get_to()][move.get_from()][move.get_to()];
}

static void update_history(Score &entry, Score bonus) {
int scaled = bonus - entry * std::abs(bonus) / 32768;
entry += scaled;
Expand Down

0 comments on commit ff38160

Please sign in to comment.