Skip to content

Commit

Permalink
fix: fix cases for mania hitresults
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxOhn committed Nov 19, 2023
1 parent 78d4526 commit 4e24567
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 37 deletions.
1 change: 1 addition & 0 deletions proptest-regressions/mania/pp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ cc 8067939c5014c26f15a25c1255fbc3452f42b159be3b1271029ba577a7da5af3 # shrinks to
cc 0924f546edd96e86ee6163aa08dd6b77fc5a6219be6766a5b5d3b6d0caa80145 # shrinks to acc = 0.5630003027452851, n320 = None, n300 = None, n200 = Some(4), n100 = None, n50 = Some(37), n_misses = None, best_case = false
cc a3c828166cc0a217e7a4e2d3592372209f886b6ea78a3da40664f3201df5a49b # shrinks to acc = 0.0, n320 = Some(0), n300 = Some(66), n200 = None, n100 = None, n50 = None, n_misses = Some(529), best_case = false
cc 1d15772c531f04fc3c0cc28ce76cf219ce7db950f36d3688bc01714a72fb8e5a # shrinks to acc = 0.0, n320 = None, n300 = None, n200 = None, n100 = None, n50 = None, n_misses = Some(595), best_case = false
cc d3ee41c1d71505bc965f52f591792539d06b370305428f1f20d798b0c525328d
66 changes: 29 additions & 37 deletions src/mania/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,19 @@ impl<'map> ManiaPP<'map> {
let mut best_dist = f64::INFINITY;
let mut n3x0 = n_objects.saturating_sub(n320 + n300 + n100 + n50 + n_misses);

let raw_n3x0 = (target_total - (4 * n_remaining) as f64
+ (2 * n100 + 3 * n50) as f64)
/ 2.0;
let min_n3x0 =
(raw_n3x0.floor() as usize).min(n_remaining.saturating_sub(n100 + n50));
let max_n3x0 =
(raw_n3x0.ceil() as usize).min(n_remaining.saturating_sub(n100 + n50));

let (min_n3x0, max_n3x0) = match (self.n320, self.n300) {
(Some(_), Some(_)) => (n320 + n300, n320 + n300),
(Some(_), None) => (n320, n320),
(None, Some(_)) => (n300, n300),
(None, None) => {
let raw_n3x0 = (target_total - (4 * n_remaining) as f64
+ (2 * n100 + 3 * n50) as f64)
/ 2.0;
let min_n3x0 = (raw_n3x0.floor() as usize)
.min(n_remaining.saturating_sub(n100 + n50));
let max_n3x0 = (raw_n3x0.ceil() as usize)
.min(n_remaining.saturating_sub(n100 + n50));

(min_n3x0, max_n3x0)
}
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
(None, None) => (min_n3x0, max_n3x0),
};

for new3x0 in min_n3x0..=max_n3x0 {
Expand Down Expand Up @@ -333,20 +331,17 @@ impl<'map> ManiaPP<'map> {
let mut best_dist = f64::INFINITY;
let mut n3x0 = n_objects.saturating_sub(n320 + n300 + n200 + n50 + n_misses);

let raw_n3x0 = (target_total - (2 * (n_remaining + n200) - n50) as f64) / 4.0;
let min_n3x0 =
(raw_n3x0.floor() as usize).min(n_remaining.saturating_sub(n200 + n50));
let max_n3x0 =
(raw_n3x0.ceil() as usize).min(n_remaining.saturating_sub(n200 + n50));

let (min_n3x0, max_n3x0) = match (self.n320, self.n300) {
(Some(_), Some(_)) => (n320 + n300, n320 + n300),
(Some(_), None) => (n320, n320),
(None, Some(_)) => (n300, n300),
(None, None) => {
let raw_n3x0 =
(target_total - (2 * (n_remaining + n200) - n50) as f64) / 4.0;
let min_n3x0 = (raw_n3x0.floor() as usize)
.min(n_remaining.saturating_sub(n200 + n50));
let max_n3x0 = (raw_n3x0.ceil() as usize)
.min(n_remaining.saturating_sub(n200 + n50));

(min_n3x0, max_n3x0)
}
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
(None, None) => (min_n3x0, max_n3x0),
};

for new3x0 in min_n3x0..=max_n3x0 {
Expand Down Expand Up @@ -377,20 +372,17 @@ impl<'map> ManiaPP<'map> {
let mut best_dist = f64::INFINITY;
let mut n3x0 = n_objects.saturating_sub(n320 + n300 + n200 + n100 + n_misses);

let raw_n3x0 = (target_total - (n_remaining + 3 * n200 + n100) as f64) / 5.0;
let min_n3x0 =
(raw_n3x0.floor() as usize).min(n_remaining.saturating_sub(n200 + n100));
let max_n3x0 =
(raw_n3x0.ceil() as usize).min(n_remaining.saturating_sub(n200 + n100));

let (min_n3x0, max_n3x0) = match (self.n320, self.n300) {
(Some(_), Some(_)) => (n320 + n300, n320 + n300),
(Some(_), None) => (n320, n320),
(None, Some(_)) => (n300, n300),
(None, None) => {
let raw_n3x0 =
(target_total - (n_remaining + 3 * n200 + n100) as f64) / 5.0;
let min_n3x0 = (raw_n3x0.floor() as usize)
.min(n_remaining.saturating_sub(n200 + n100));
let max_n3x0 = (raw_n3x0.ceil() as usize)
.min(n_remaining.saturating_sub(n200 + n100));

(min_n3x0, max_n3x0)
}
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
(None, None) => (min_n3x0, max_n3x0),
};

for new3x0 in min_n3x0..=max_n3x0 {
Expand Down

0 comments on commit 4e24567

Please sign in to comment.