QSEARCH_TT, QCAPTURE_INIT, QCAPTURE, QCHECK_INIT, QCHECK
};
- // Helper filter used with select()
- const auto Any = [](){ return true; };
-
// partial_insertion_sort() sorts moves in descending order up to and including
// a given limit. The order of moves smaller than the limit is left unspecified.
void partial_insertion_sort(ExtMove* begin, ExtMove* end, int limit) {
assert(d > DEPTH_ZERO);
stage = pos.checkers() ? EVASION_TT : MAIN_TT;
- ttMove = pos.pseudo_legal(ttm) ? ttm : MOVE_NONE;
+ ttMove = ttm && pos.pseudo_legal(ttm) ? ttm : MOVE_NONE;
stage += (ttMove == MOVE_NONE);
}
assert(d <= DEPTH_ZERO);
stage = pos.checkers() ? EVASION_TT : QSEARCH_TT;
- ttMove = pos.pseudo_legal(ttm)
- && (depth > DEPTH_QS_RECAPTURES || to_sq(ttm) == recaptureSquare) ? ttm : MOVE_NONE;
+ ttMove = ttm
+ && (depth > DEPTH_QS_RECAPTURES || to_sq(ttm) == recaptureSquare)
+ && pos.pseudo_legal(ttm) ? ttm : MOVE_NONE;
stage += (ttMove == MOVE_NONE);
}
assert(!pos.checkers());
stage = PROBCUT_TT;
- ttMove = pos.pseudo_legal(ttm)
+ ttMove = ttm
&& pos.capture(ttm)
+ && pos.pseudo_legal(ttm)
&& pos.see_ge(ttm, threshold) ? ttm : MOVE_NONE;
stage += (ttMove == MOVE_NONE);
}
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
+ (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
+ (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
- + (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)];
+ + (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
+ + (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)] / 2;
else // Type == EVASIONS
{
/* fallthrough */
case REFUTATION:
- if (select<Next>([&](){ return !pos.capture(move)
+ if (select<Next>([&](){ return move != MOVE_NONE
+ && !pos.capture(move)
&& pos.pseudo_legal(move); }))
return move;
++stage;
/* fallthrough */
case BAD_CAPTURE:
- return select<Next>(Any);
+ return select<Next>([](){ return true; });
case EVASION_INIT:
cur = moves;
/* fallthrough */
case EVASION:
- return select<Best>(Any);
+ return select<Best>([](){ return true; });
case PROBCUT:
return select<Best>([&](){ return pos.see_ge(move, threshold); });
/* fallthrough */
case QCHECK:
- return select<Next>(Any);
+ return select<Next>([](){ return true; });
}
assert(false);