Skip to content

Commit

Permalink
2 ply conthist - #80
Browse files Browse the repository at this point in the history
STC:
ELO   | 4.09 +- 3.25 (95%)
SPRT  | 10.0+0.10s Threads=1 Hash=16MB
LLR   | 2.99 (-2.94, 2.94) [0.00, 5.00]
GAMES | N: 20496 W: 4905 L: 4664 D: 10927

LTC:
ELO   | 4.15 +- 3.30 (95%)
SPRT  | 60.0+0.60s Threads=1 Hash=256MB
LLR   | 2.95 (-2.94, 2.94) [0.00, 5.00]
GAMES | N: 18936 W: 4331 L: 4105 D: 10500

Bench: 9923161
  • Loading branch information
SzilBalazs authored Sep 3, 2023
1 parent 31b720e commit f4979b9
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 f4979b9

Please sign in to comment.