- // Step 2. Check for aborted search and immediate draw
- // Enforce node limit here. FIXME: This only works with 1 search thread.
- if (Limits.nodes && pos.nodes_searched() >= Limits.nodes)
- Signals.stop = true;
-
- if (( Signals.stop
- || pos.is_draw<false>()
- || ss->ply > MAX_PLY) && !RootNode)
- return VALUE_DRAW;
-
- // Step 3. Mate distance pruning. Even if we mate at the next move our score
- // would be at best mate_in(ss->ply+1), but if alpha is already bigger because
- // a shorter mate was found upward in the tree then there is no need to search
- // further, we will never beat current alpha. Same logic but with reversed signs
- // applies also in the opposite condition of being mated instead of giving mate,
- // in this case return a fail-high score.