Skip to content

Commit

Permalink
review: fix div-by-zero causing score to be NaN, close #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Equim-chan committed Oct 21, 2020
1 parent d844ef2 commit 75d5704
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,14 @@ pub fn review<'a>(review_args: &'a ReviewArgs) -> Result<Review> {
}

Some(Some(actual_ev)) => {
let move_score = 1f64 - (expected_ev - actual_ev) / (expected_ev - min_ev);
let range = expected_ev - min_ev;
let error = expected_ev - actual_ev;
let move_score = if range > 0f64 {
1f64 - error / range
} else {
1f64
};

let dev = expected_ev - actual_ev;
if dev <= deviation_threshold {
if verbose {
Expand Down

0 comments on commit 75d5704

Please sign in to comment.