1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Fix a crash when reaching PLY_MAX in a check position

In this case we call evaluate() being in check and this
is not allowed.

Bug found testing with reduced PLY_MAX value as suggested
by Miguel A. Ballicora on talkchess.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-10-12 15:19:29 +01:00
parent 181d34e5a0
commit d8e7ce1863
2 changed files with 5 additions and 4 deletions

View file

@ -309,6 +309,7 @@ Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
assert(pos.is_ok());
assert(threadID >= 0 && threadID < THREAD_MAX);
assert(!pos.is_check());
memset(&ei, 0, sizeof(EvalInfo));

View file

@ -1048,7 +1048,7 @@ namespace {
EvalInfo ei;
if (ply >= PLY_MAX - 1)
return evaluate(pos, ei, threadID);
return pos.is_check() ? quick_evaluate(pos) : evaluate(pos, ei, threadID);
// Mate distance pruning
Value oldAlpha = alpha;
@ -1238,7 +1238,7 @@ namespace {
EvalInfo ei;
if (ply >= PLY_MAX - 1)
return evaluate(pos, ei, threadID);
return pos.is_check() ? quick_evaluate(pos) : evaluate(pos, ei, threadID);
// Mate distance pruning
if (value_mated_in(ply) >= beta)
@ -1529,8 +1529,8 @@ namespace {
else
staticValue = evaluate(pos, ei, threadID);
if (ply == PLY_MAX - 1)
return evaluate(pos, ei, threadID);
if (ply >= PLY_MAX - 1)
return pos.is_check() ? quick_evaluate(pos) : evaluate(pos, ei, threadID);
// Initialize "stand pat score", and return it immediately if it is
// at least beta.