Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,10 @@ params! {
fhp_depth_limit: [2.2592714],
fhp_margin_scalar: [170.64804, 18.890638],
fhp_margin_depth: [19.776033],
razoring_depth_limit: [4.0],
razoring_scalar: [30.0234, 21.85148],
razoring_depth: [8.186248],
rfp_depth_limit: [12.0],
rfp_margin_scalar: [10.407456, 10.813848, -6.300178],
rfp_margin_depth: [1.3744049, -0.13397427],
rfp_margin_is_improving: [-6.637267],
Expand Down
4 changes: 2 additions & 2 deletions lib/search/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ impl<'a> Searcher<'a> {
if alpha >= beta || upper <= alpha || lower >= beta || ply >= Ply::MAX {
return Ok(Pv::empty(stand_pat).clip(lower, upper));
} else if !IS_PV && !is_check {
if !alpha.is_winning() {
if alpha.get().abs() < 1000 && depth < *Params::razoring_depth_limit(0) {
let margin = convolve([
(1.0, Params::razoring_scalar(..)),
(depth, Params::razoring_depth(..)),
Expand All @@ -650,7 +650,7 @@ impl<'a> Searcher<'a> {
}
}

if !beta.is_losing() {
if !beta.is_losing() && depth < *Params::rfp_depth_limit(0) {
let margin = convolve([
(1.0, Params::rfp_margin_scalar(..)),
(depth, Params::rfp_margin_depth(..)),
Expand Down
26 changes: 10 additions & 16 deletions lib/search/score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ impl Score {
Self::new(0)
}

/// The tablebase loss score at `ply`.
/// The tablebase losing score at `ply`.
#[inline(always)]
pub fn losing(ply: Ply) -> Self {
Self::mated(Ply::upper()).relative_to_ply(ply) + 1
}

/// The maximum value.
/// The tablebase winning score at `ply`.
#[inline(always)]
pub fn winning(ply: Ply) -> Self {
Self::mating(Ply::upper()).relative_to_ply(ply) - 1
Expand All @@ -73,9 +73,9 @@ impl Score {
/// Returns number of plies to mate, if one is in the horizon.
#[inline(always)]
pub fn mate(self) -> Mate {
if self.is_loss() {
if self.is_mated() {
Mate::Mated((self - Score::lower()).saturate())
} else if self.is_win() {
} else if self.is_mating() {
Mate::Mating((Score::upper() - self).saturate())
} else {
Mate::None
Expand Down Expand Up @@ -126,21 +126,15 @@ impl Score {

/// Returns true if the score represents a won position.
#[inline(always)]
pub fn is_win(self) -> bool {
pub fn is_mating(self) -> bool {
self > Self::winning(zeroed())
}

/// Returns true if the score represents a lost position.
#[inline(always)]
pub fn is_loss(self) -> bool {
pub fn is_mated(self) -> bool {
self < Self::losing(zeroed())
}

/// Returns true if the score represents a won or lost position.
#[inline(always)]
pub fn is_decided(self) -> bool {
self.is_win() || self.is_loss()
}
}

impl Flip for Score {
Expand Down Expand Up @@ -196,13 +190,13 @@ mod tests {
}

#[proptest]
fn mating_implies_is_win(p: Ply) {
assert!(Score::mating(p).is_win());
fn mating_implies_is_mating(p: Ply) {
assert!(Score::mating(p).is_mating());
}

#[proptest]
fn mated_implies_is_loss(p: Ply) {
assert!(Score::mated(p).is_loss());
fn mated_implies_is_mated(p: Ply) {
assert!(Score::mated(p).is_mated());
}

#[proptest]
Expand Down
Loading