pub fn get_next_move(
context: &mut SearchContext,
state: &mut MoveGenState
) -> 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:
- MoveGenStage::ReadyToCheckHashMove - default state, prepares hash move if possible
- MoveGenStage::HashMove - returns hashmove if possible
- MoveGenStage::ReadyToGenerateCaptures - generates all captures in the position
- MoveGenStage::Captures - returns subsequent elements until the end or score is less than [MOVE_ORDERING_WINNING_CAPTURES_OFFSET]
- MoveGenStage::ReadyToGenerateKillers - generates all killer moves in the position
- MoveGenStage::Killers - returns subsequent elements until all killer moves are processed
- MoveGenStage::ReadyToGenerateCounters - generates all countermoves in the position
- MoveGenStage::Counters - returns subsequent elements until all countermoves are processed
- MoveGenStage::ReadyToGenerateQuiets - generates all quiet moves in the position
- MoveGenStage::AllGenerated - returns all subsequent elements until the end
If the last stage is set and there are no more moves, None is returned.