Function inanis::engine::search::run_internal

source ·
fn run_internal<const ROOT: bool, const PV: bool, const DIAG: bool>(
    context: &mut SearchContext,
    depth: i8,
    ply: u16,
    alpha: i16,
    beta: i16,
    allow_null_move: bool,
    friendly_king_checked: bool
) -> i16
Expand description

Entry point of the regular search, with generic ROOT parameter indicating if this is the root node where the moves filterigh might happen, and PV parameter determining if the current node is a PV (principal variation) node in the PVS framework. The implementation contains a typical alpha-beta approach, together with a bunch of reductions and prunings to optimize search. The most important parameter here, context, contains the current state of the search, board state, statistics, and is passed by reference to all nodes. Besides obvious parameters like depth, ply, alpha and beta, there’s also allow_null_move which prevents two null move checks in a row, and friendly_king_checked which is used to share friendly king check status between nodes (it’s always calculated one depth earlier, as it’s used as one of the LMR constraints). If DIAG is set to true, additional statistics will be gathered (with a small performance penalty).

Search steps for PV node:

Search steps for non-PV node: