Assorted trivial cleanups

- Cleanups by Alain
- Group king attacks and king defenses
- Signature of futility_move_count()
- Use is_discovery_check_on_king()
- Simplify backward definition
- Use static asserts in move generator
- Factor a statement in move generator

No functional change
This commit is contained in:
Stéphane Nicolet
2019-10-19 02:20:38 +02:00
parent 7e89a71624
commit 90c0385724
9 changed files with 30 additions and 35 deletions
+6 -6
View File
@@ -75,7 +75,7 @@ namespace {
return (r + 520) / 1024 + (!i && r > 999);
}
constexpr int futility_move_count(bool improving, int depth) {
constexpr int futility_move_count(bool improving, Depth depth) {
return (5 + depth * depth) * (1 + improving) / 2;
}
@@ -594,7 +594,7 @@ namespace {
Move ttMove, move, excludedMove, bestMove;
Depth extension, newDepth;
Value bestValue, value, ttValue, eval, maxValue;
bool ttHit, ttPv, inCheck, givesCheck, improving, doLMR, priorCapture;
bool ttHit, ttPv, inCheck, givesCheck, improving, didLMR, priorCapture;
bool captureOrPromotion, doFullDepthSearch, moveCountPruning, ttCapture, singularLMR;
Piece movedPiece;
int moveCount, captureCount, quietCount;
@@ -1151,17 +1151,17 @@ moves_loop: // When in check, search starts from here
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d, true);
doFullDepthSearch = (value > alpha && d != newDepth), doLMR = true;
doFullDepthSearch = (value > alpha && d != newDepth), didLMR = true;
}
else
doFullDepthSearch = !PvNode || moveCount > 1, doLMR = false;
doFullDepthSearch = !PvNode || moveCount > 1, didLMR = false;
// Step 17. Full depth search when LMR is skipped or fails high
if (doFullDepthSearch)
{
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode);
if (doLMR && !captureOrPromotion)
if (didLMR && !captureOrPromotion)
{
int bonus = value > alpha ? stat_bonus(newDepth)
: -stat_bonus(newDepth);
@@ -1466,7 +1466,7 @@ moves_loop: // When in check, search starts from here
// Don't search moves with negative SEE values
if ( (!inCheck || evasionPrunable)
&& (!givesCheck || !(pos.blockers_for_king(~pos.side_to_move()) & from_sq(move)))
&& !(givesCheck && pos.is_discovery_check_on_king(~pos.side_to_move(), move))
&& !pos.see_ge(move))
continue;