Skip to content

Commit

Permalink
Add IID on PV nodes (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes authored May 1, 2024
2 parents 17516bf + 9e2c784 commit c63411e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/search/pvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ fn pvs<const ROOT: bool, const MAIN_THREAD: bool, const ALLOW_NMR: bool>(
// Position and node type considerations.
let is_check = position.is_check();
let may_be_zug = may_be_zugzwang(position);
let is_pv = alpha != beta - 1;

// Null move pruning: if we "pass" our turn and still get a beta cutoff,
// this position is far too good to be true.
Expand Down Expand Up @@ -183,6 +184,23 @@ fn pvs<const ROOT: bool, const MAIN_THREAD: bool, const ALLOW_NMR: bool>(
}
}

// Internal iterative deepening: get a hash move from a reduced search.
// This is useless in most cases, but can be very useful in some
// where standard move ordering fails to be decent.
if is_pv && !is_check && !ROOT && depth >= 4 && table.get_hash_move(position).is_none() {
let (_, iid_count) = pvs::<true, MAIN_THREAD, false>(
position,
depth.saturating_sub(2),
alpha,
beta,
table.clone(),
constraint,
history,
ply,
);
count += iid_count;
}

// Prepare move generation and sorting. This is lazy and works in stages.
let mut picker =
MovePicker::<false>::new(position, table.clone(), ply, ROOT && !MAIN_THREAD).peekable();
Expand Down Expand Up @@ -282,7 +300,7 @@ fn pvs<const ROOT: bool, const MAIN_THREAD: bool, const ALLOW_NMR: bool>(
best_move,
depth,
ply,
ROOT && MAIN_THREAD,
ROOT,
);
}

Expand Down

0 comments on commit c63411e

Please sign in to comment.