- bestScore = -10000000;
- bestIndex = -1;
- for (int i = movesPicked; i < numOfMoves; i++)
- {
- if (moves[i].score < 0)
- {
- // Losing capture, move it to the badCaptures[] array
- assert(numOfBadCaptures < 63);
- badCaptures[numOfBadCaptures++] = moves[i];
- moves[i--] = moves[--numOfMoves];
- }
- else if (moves[i].score > bestScore)
- {
- bestIndex = i;
- bestScore = moves[i].score;
- }
- }
- if (bestIndex != -1) // Found a good capture
- {
- move = moves[bestIndex].move;\r
- moves[bestIndex] = moves[movesPicked++];
- if ( move != ttMove
- && move != mateKiller
- && pos.move_is_legal(move, pinned))
- return move;
- }
+ bestIndex = find_best_index();
+ move = moves[bestIndex].move;
+ moves[bestIndex] = moves[movesPicked++];
+ if ( move != ttMove
+ && move != mateKiller
+ && pos.pl_move_is_legal(move, pinned))
+ return move;