diff --git a/crates/engine/src/evaluator.rs b/crates/engine/src/evaluator.rs index af0a21d..349f7e5 100644 --- a/crates/engine/src/evaluator.rs +++ b/crates/engine/src/evaluator.rs @@ -83,6 +83,7 @@ pub trait Evaluator { /// [BatchEvaluator] is a subtrait of [Evaluator]. The function [Evaluator::eval_batch] is /// implemented by default. This trait is meant for evaluating all legal moves at once. +/// /// An example is [crate::onnx::OnnxEvaluator], where feeding several positions at once to the /// neural net is more performant than evaluating them one by one. /// diff --git a/crates/engine/src/position.rs b/crates/engine/src/position.rs index 7b2e950..8a6c1e0 100644 --- a/crates/engine/src/position.rs +++ b/crates/engine/src/position.rs @@ -306,7 +306,7 @@ impl Position { #[inline] fn can_move_internally(&self, from: usize, die: usize) -> bool { - return if self.pips[from] < 1 { + if self.pips[from] < 1 { // no checker to move false } else if from > die { @@ -321,7 +321,7 @@ impl Position { // from < die, bear off let checker_on_bigger_pip = self.pips[from + 1..X_BAR].iter().any(|x| x > &0); !checker_on_bigger_pip - }; + } } /// Works for all of moves, including those from the bar diff --git a/crates/engine/src/position/conversion.rs b/crates/engine/src/position/conversion.rs index cfdb674..540b48d 100644 --- a/crates/engine/src/position/conversion.rs +++ b/crates/engine/src/position/conversion.rs @@ -3,7 +3,8 @@ use base64::engine::general_purpose; use base64::Engine; use std::collections::HashMap; -/// Simple way to create positions for testing +/// Simple way to create positions for testing. +/// /// The starting position would be: /// pos!(x 24:2, 13:5, 8:3, 6:5; o 19:5, 17:3, 12:5, 1:2) /// The order is not important, so this is equivalent: diff --git a/crates/engine/src/position/double_moves.rs b/crates/engine/src/position/double_moves.rs index cf280eb..6101dfa 100644 --- a/crates/engine/src/position/double_moves.rs +++ b/crates/engine/src/position/double_moves.rs @@ -117,7 +117,7 @@ impl Position { return max_return_value; } // bear off moves - return match position.pips.iter().rposition(|&p| p > 0) { + match position.pips.iter().rposition(|&p| p > 0) { None => number_of_checkers, Some(biggest_pip) => { let bearoff_checkers: u32 = if biggest_pip > 6 { @@ -136,7 +136,7 @@ impl Position { number_of_checkers += bearoff_checkers; min(number_of_checkers, max_return_value) } - }; + } } } diff --git a/crates/logic/src/bg_move.rs b/crates/logic/src/bg_move.rs index 88d1576..d5c3a85 100644 --- a/crates/logic/src/bg_move.rs +++ b/crates/logic/src/bg_move.rs @@ -19,6 +19,7 @@ pub struct BgMove { #[derive(Debug, PartialEq)] #[cfg_attr(feature = "web", derive(Serialize, ToSchema))] /// Single movement of one checker. We always move from bigger pips to smaller pips. +/// /// If the same checker is moved more than once, multiple `MoveDetail`s are given. /// Therefore: `from > to` and `from - to <= 6`. pub struct MoveDetail { diff --git a/crates/web/src/web_api.rs b/crates/web/src/web_api.rs index c68dc08..8602692 100644 --- a/crates/web/src/web_api.rs +++ b/crates/web/src/web_api.rs @@ -101,6 +101,8 @@ pub struct MoveInfo { // This is similar to evaluator::Probabilities. But while the former serves // as a model for calculations, this is more like a view model for the web API. // While in evaluator::Probabilities all 6 numbers add up to 1.0, this is different. +/// Chances for winning/losing normal/gammon/backgammon. +/// /// `win` includes the chances to win gammon or BG. /// `winG` includes the chances to win BG and `loseG` includes the chance to lose BG. /// This way we use the same format as earlier engines like GnuBG have done.