- while (true)
- {
- // If we already have a list of generated moves, pick the best move from
- // the list, and return it.
- move = pick_move_from_list();
- if (move != MOVE_NONE)
- {
- assert(move_is_ok(move));
- return move;
- }
-
- // Next phase
- phasePtr++;
- switch (*phasePtr) {
-
- case PH_NULL_MOVE:
- break;
-
- case PH_TT_MOVES:
- movesPicked = 0; // This is used as index to ttMoves[]
- break;
-
- case PH_GOOD_CAPTURES:
- numOfMoves = generate_captures(pos, moves);
- score_captures();
- std::sort(moves, moves + numOfMoves);
- movesPicked = 0;
- break;
-
- case PH_KILLERS:
- movesPicked = 0; // This is used as index to killers[]
- break;
-
- case PH_NONCAPTURES:
- numOfMoves = generate_noncaptures(pos, moves);
- score_noncaptures();
- std::sort(moves, moves + numOfMoves);
- movesPicked = 0;
- break;
-
- case PH_BAD_CAPTURES:
- // Bad captures SEE value is already calculated so just sort them
- // to get SEE move ordering.
- std::sort(badCaptures, badCaptures + numOfBadCaptures);
- movesPicked = 0;
- break;
-
- case PH_EVASIONS:
- assert(pos.is_check());
- numOfMoves = generate_evasions(pos, moves, pinned);
- score_evasions();
- std::sort(moves, moves + numOfMoves);
- movesPicked = 0;
- break;
-
- case PH_QCAPTURES:
- numOfMoves = generate_captures(pos, moves);
- score_captures();
- std::sort(moves, moves + numOfMoves);
- movesPicked = 0;
- break;
-
- case PH_QCHECKS:
- // Perhaps we should order moves move here? FIXME
- numOfMoves = generate_non_capture_checks(pos, moves, dc);
- movesPicked = 0;
- break;
-
- case PH_STOP:
- return MOVE_NONE;
-
- default:
- assert(false);
- return MOVE_NONE;
- }
- }
-}