/// next_move() is the most important method of the MovePicker class. It returns /// a new pseudo legal move every time it is called, until there are no more moves /// left. It picks the move with the biggest value from a list of generated moves /// taking care not to return the ttMove if it has already been searched. public Move next_move_false() { Move move; while (true) { while (cur == end) { generate_next_stage(); } switch (stage) { case StagesS.MAIN_SEARCH: case StagesS.EVASION: case StagesS.QSEARCH_0: case StagesS.QSEARCH_1: case StagesS.PROBCUT: ++cur; return(ttMove); case StagesS.CAPTURES_S1: move = moves[pick_best(moves, cur++, end)].move; if (move != ttMove) { if (pos.see_sign(move) >= ValueS.VALUE_ZERO) { return(move); } // Losing capture, move it to the tail of the array moves[endBadCaptures--].move = move; } break; case StagesS.KILLERS_S1: move = moves[cur++].move; if (move != MoveS.MOVE_NONE && move != ttMove && pos.pseudo_legal(move) && !pos.capture(move)) { return(move); } break; case StagesS.QUIETS_1_S1: case StagesS.QUIETS_2_S1: move = moves[cur++].move; if (move != ttMove && move != moves[Types.MAX_MOVES].move && move != moves[Types.MAX_MOVES + 1].move && move != moves[Types.MAX_MOVES + 2].move && move != moves[Types.MAX_MOVES + 3].move && move != moves[Types.MAX_MOVES + 4].move && move != moves[Types.MAX_MOVES + 5].move) { return(move); } break; case StagesS.BAD_CAPTURES_S1: return(moves[cur--].move); case StagesS.EVASIONS_S2: case StagesS.CAPTURES_S3: case StagesS.CAPTURES_S4: move = moves[pick_best(moves, cur++, end)].move; if (move != ttMove) { return(move); } break; case StagesS.CAPTURES_S5: move = moves[pick_best(moves, cur++, end)].move; if (move != ttMove && pos.see(move) > captureThreshold) { return(move); } break; case StagesS.CAPTURES_S6: move = moves[pick_best(moves, cur++, end)].move; if (Types.to_sq(move) == recaptureSquare) { return(move); } break; case StagesS.QUIET_CHECKS_S3: move = moves[cur++].move; if (move != ttMove) { return(move); } break; case StagesS.STOP: return(MoveS.MOVE_NONE); default: Debug.Assert(false); break; } } }