- 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);
- while(movesPicked < numOfMoves) {
- bestScore = -10000000;
- bestIndex = -1;
- for(int i = movesPicked; i < numOfMoves; i++)
- if(moves[i].score > bestScore) {
- bestIndex = i;
- bestScore = moves[i].score;
- }
-
- if(bestIndex != -1) {
- move = moves[bestIndex].move;\r
- moves[bestIndex] = moves[movesPicked++];
- return move;
- }
- }
- break;
-
- case PH_BAD_CAPTURES:
- assert(!pos->is_check());
- assert(badCapturesPicked >= 0);
- // It's probably a good idea to use SEE move ordering here, instead
- // of just picking the first move. FIXME
- while(badCapturesPicked < numOfBadCaptures) {
- move = badCaptures[badCapturesPicked++].move;
- if(move != ttMove && move != mateKiller &&
- pos->move_is_legal(move, pinned))
- return move;
- }
- break;
-
- case PH_QCAPTURES:
- assert(!pos->is_check());
- assert(movesPicked >= 0);
- while(movesPicked < numOfMoves) {
- bestScore = -10000000;
- if(movesPicked < 4) {
- 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++];
- // Remember to change the line below if we decide to hash the qsearch!
- // Maybe also postpone the legality check until after futility pruning?
- if(/* move != ttMove && */ pos->move_is_legal(move, pinned))
- return move;
- }
- }
- break;
-
- case PH_QCHECKS:
- assert(!pos->is_check());
- assert(movesPicked >= 0);
- // Perhaps we should do something better than just picking the first
- // move here? FIXME
- while(movesPicked < numOfMoves) {
- move = moves[movesPicked++].move;
- // Remember to change the line below if we decide to hash the qsearch!
- if(/* move != ttMove && */ pos->move_is_legal(move, pinned))
- return move;
- }
- break;
-
- default:
- break;