Skip to content

Commit ca4ac66

Browse files
authored
Add a qsearch limit against too deep recursion (#958)
Closes #957.
1 parent a8d6b25 commit ca4ac66

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/search.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,10 @@ namespace {
15541554
if (ss->ply >= MAX_PLY)
15551555
return !ss->inCheck ? evaluate(pos) : VALUE_DRAW;
15561556

1557+
// Safeguard against too deep recursions in quiescence search
1558+
if (depth < DEPTH_QS_MAX && !ss->inCheck)
1559+
return evaluate(pos);
1560+
15571561
assert(0 <= ss->ply && ss->ply < MAX_PLY);
15581562

15591563
// Decide whether or not to include checks: this fixes also the type of

src/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ enum : int {
484484
DEPTH_QS_CHECKS = 0,
485485
DEPTH_QS_NO_CHECKS = -1,
486486
DEPTH_QS_RECAPTURES = -5,
487+
DEPTH_QS_MAX = -32,
487488

488489
DEPTH_NONE = -6,
489490

0 commit comments

Comments
 (0)