Skip to content

Commit

Permalink
Add simple protections for search explosions due to extensions (#448)
Browse files Browse the repository at this point in the history
Bench: 4897161

STC

ELO   | 1.69 +- 2.62 (95%)
SPRT  | 10.0+0.10s Threads=1 Hash=8MB
LLR   | 2.97 (-2.94, 2.94) [-2.50, 0.50]
GAMES | N: 32520 W: 7945 L: 7787 D: 16788

LTC

ELO   | 0.07 +- 2.36 (95%)
SPRT  | 60.0+0.60s Threads=1 Hash=64MB
LLR   | 1.12 (-2.94, 2.94) [-2.50, 0.50]
GAMES | N: 37456 W: 8476 L: 8468 D: 20512
  • Loading branch information
jhonnold authored Jan 16, 2023
1 parent f2aaf92 commit 6c17e81
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
EXE = berserk
SRC = *.c pyrrhic/tbprobe.c
CC = gcc
VERSION = 20230116
VERSION = 20230116b
MAIN_NETWORK = networks/berserk-bf1200bb0547.nn
EVALFILE = $(MAIN_NETWORK)
DEFS = -DVERSION=\"$(VERSION)\" -DEVALFILE=\"$(EVALFILE)\" -DNDEBUG
Expand Down
66 changes: 34 additions & 32 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,40 +548,42 @@ int Negamax(int alpha, int beta, int depth, int cutnode, ThreadData* thread, PV*
// other moves at a shallow depth on a nullwindow that is somewhere below
// the tt evaluation implemented using "skip move" recursion like in SF
// (allows for reductions when doing singular search)
if (!isRoot && depth >= 7 && tt && move == hashMove && TTDepth(tt) >= depth - 3 && (tt->flags & TT_LOWER) &&
abs(ttScore) < WINNING_ENDGAME) {
int sBeta = max(ttScore - 3 * depth / 2, -CHECKMATE);
int sDepth = depth / 2 - 1;

ss->skip = move;
score = Negamax(sBeta - 1, sBeta, sDepth, cutnode, thread, pv, ss);
ss->skip = NULL_MOVE;

// no score failed above sBeta, so this is singular
if (score < sBeta) {
singularExtension = 1;

if (!isPV && score < sBeta - 35 && ss->de <= 6) {
extension = 2;
ss->de = (ss - 1)->de + 1;
} else {
extension = 1;
}
} else if (sBeta >= beta)
return sBeta;
else if (ttScore >= beta)
extension = -1;
}
if (ss->ply < thread->depth * 2) {
if (!isRoot && depth >= 7 && tt && move == hashMove && TTDepth(tt) >= depth - 3 && (tt->flags & TT_LOWER) &&
abs(ttScore) < WINNING_ENDGAME) {
int sBeta = max(ttScore - 3 * depth / 2, -CHECKMATE);
int sDepth = depth / 2 - 1;

ss->skip = move;
score = Negamax(sBeta - 1, sBeta, sDepth, cutnode, thread, pv, ss);
ss->skip = NULL_MOVE;

// no score failed above sBeta, so this is singular
if (score < sBeta) {
singularExtension = 1;

if (!isPV && score < sBeta - 35 && ss->de <= 6) {
extension = 2;
ss->de = (ss - 1)->de + 1;
} else {
extension = 1;
}
} else if (sBeta >= beta)
return sBeta;
else if (ttScore >= beta)
extension = -1;
}

// history extension - if the tt move has a really good history score,
// extend. thank you to Connor, author of Seer for this idea
else if (!isRoot && depth >= 7 && tt && move == hashMove && history >= 98304)
extension = 1;
// history extension - if the tt move has a really good history score,
// extend. thank you to Connor, author of Seer for this idea
else if (!isRoot && depth >= 7 && tt && move == hashMove && history >= 98304 && abs(ttScore) < WINNING_ENDGAME)
extension = 1;

// re-capture extension - looks for a follow up capture on the same square
// as the previous capture
else if (!isRoot && isPV && IsRecapture(ss, move))
extension = 1;
// re-capture extension - looks for a follow up capture on the same square
// as the previous capture
else if (!isRoot && isPV && IsRecapture(ss, move))
extension = 1;
}

ss->move = move;
ss->ch = &thread->ch[IsCap(move)][Moving(move)][To(move)];
Expand Down

0 comments on commit 6c17e81

Please sign in to comment.