From 1a733d3a0213e4ae3f34dd21ff9876b733ed4a2d Mon Sep 17 00:00:00 2001 From: Bruno Dutra Date: Sun, 19 Nov 2023 12:17:46 +0100 Subject: [PATCH] partially inline struct Engine --- lib/search/engine.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/search/engine.rs b/lib/search/engine.rs index 000038b4..38a99776 100644 --- a/lib/search/engine.rs +++ b/lib/search/engine.rs @@ -37,6 +37,7 @@ pub struct Engine { } impl Default for Engine { + #[inline(always)] fn default() -> Self { Self::new() } @@ -50,11 +51,13 @@ impl Engine { } /// Initializes the engine with the default [`Options`]. + #[inline(always)] pub fn new() -> Self { Self::with_options(Options::default()) } /// Initializes the engine with the given [`Options`]. + #[inline(always)] pub fn with_options(options: Options) -> Self { Engine { tt: TranspositionTable::new(options.hash), @@ -90,6 +93,7 @@ impl Engine { /// An implementation of [mate distance pruning]. /// /// [mate distance pruning]: https://www.chessprogramming.org/Mate_Distance_Pruning + #[inline(always)] fn mdp(&self, ply: Ply, bounds: &Range) -> (Score, Score) { let lower = Score::LOWER.normalize(ply); let upper = (Score::UPPER - 1).normalize(ply); // One can't mate in 0 plies! @@ -101,6 +105,7 @@ impl Engine { /// An implementation of [null move pruning]. /// /// [null move pruning]: https://www.chessprogramming.org/Null_Move_Pruning + #[inline(always)] fn nmp(&self, pos: &Position, guess: Score, beta: Score, depth: Depth) -> Option { let turn = pos.turn(); let r = match pos.by_color(turn).len() - pos.by_piece(Piece(turn, Role::Pawn)).len() { @@ -120,6 +125,7 @@ impl Engine { /// An implementation of [late move pruning]. /// /// [late move pruning]: https://www.chessprogramming.org/Late_Move_Reductions + #[inline(always)] fn lmp(&self, next: &Position, guess: Score, alpha: Score, depth: Depth) -> Option { let r = match (alpha - guess).get() { ..=90 => return None,