Function inanis::engine::search::get_next_move
source · fn get_next_move<const DIAG: bool>(
context: &mut SearchContext,
stage: &mut MoveGeneratorStage,
moves: &mut [MaybeUninit<Move>; 218],
move_scores: &mut [MaybeUninit<i16>; 218],
move_index: &mut usize,
move_number: &mut usize,
moves_count: &mut usize,
evasion_mask: &mut u64,
hash_move: Move,
ply: u16,
friendly_king_checked: bool
) -> Option<(Move, i16)>
Expand description
Gets a next move to analyze. This function acts as pseudo-iterator and takes care about managing move generator stages, which is basically a state machine (https://en.wikipedia.org/wiki/Finite-state_machine) with following rules:
- MoveGeneratorStage::ReadyToCheckHashMove - default state, prepares hash move if possible
- MoveGeneratorStage::HashMove - returns hashmove if possible
- MoveGeneratorStage::ReadyToGenerateCaptures - generates all captures in the position
- MoveGeneratorStage::Captures - returns subsequent elements until the end or score is less than MOVE_ORDERING_WINNING_CAPTURES_OFFSET
- MoveGeneratorStage::ReadyToGenerateQuietMoves - generates all quiet moves in the position
- MoveGeneratorStage::AllGenerated - returns subsequent elements until the end
Both MoveGeneratorStage::ReadyToGenerateCaptures and MoveGeneratorStage::ReadyToGenerateQuietMoves are generating moves and assigning scores for move ordering purposes. If the last stage is set and there are no more moves, None is returned.