- assert(!pos.is_check());
- assert(movesPicked >= 0);
- while (movesPicked < numOfMoves)
- {
- // If this is a PV node or we have only picked a few moves, scan
- // the entire move list for the best move. If many moves have already
- // been searched and it is not a PV node, we are probably failing low
- // anyway, so we just pick the first move from the list.
- if (pvNode || movesPicked < 12)
- {
- bestScore = -10000000;
- bestIndex = -1;
- for (int i = movesPicked; i < numOfMoves; i++)
- if(moves[i].score > bestScore)
- {
- bestIndex = i;
- bestScore = moves[i].score;
- }
- } else
- bestIndex = movesPicked;
-
- if (bestIndex != -1)
- {
- move = moves[bestIndex].move;\r
- moves[bestIndex] = moves[movesPicked++];
- if ( move != ttMove
- && move != mateKiller
- && pos.move_is_legal(move, pinned))
- return move;
- }
- }
- break;
-
- case PH_EVASIONS:
- assert(pos.is_check());
- assert(movesPicked >= 0);