Skip to content

Commit

Permalink
partially inline struct Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
brunocodutra committed Nov 21, 2023
1 parent cd6611d commit 1a733d3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/search/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct Engine {
}

impl Default for Engine {
#[inline(always)]
fn default() -> Self {
Self::new()
}
Expand All @@ -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),
Expand Down Expand Up @@ -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, Score) {
let lower = Score::LOWER.normalize(ply);
let upper = (Score::UPPER - 1).normalize(ply); // One can't mate in 0 plies!
Expand All @@ -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<Depth> {
let turn = pos.turn();
let r = match pos.by_color(turn).len() - pos.by_piece(Piece(turn, Role::Pawn)).len() {
Expand All @@ -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<Depth> {
let r = match (alpha - guess).get() {
..=90 => return None,
Expand Down

0 comments on commit 1a733d3

Please sign in to comment.