Skip to content

Commit

Permalink
fix: adjust n3x0 limits
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxOhn committed Nov 3, 2023
1 parent 8d1fcda commit 99e40e0
Showing 1 changed file with 50 additions and 46 deletions.
96 changes: 50 additions & 46 deletions src/mania/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,21 @@ impl<'map> ManiaPP<'map> {
let mut best_dist = f64::INFINITY;
let mut n3x0 = n_objects.saturating_sub(n320 + n300 + n100 + n50 + n_misses);

let max_left = n_remaining.saturating_sub(n100 + n50);

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(max_left);
let max_n3x0 = (raw_n3x0.ceil() as usize).min(max_left);

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(_), Some(_)) => {
(max_left.min(n320 + n300), max_left.min(n320 + n300))
}
(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 +333,19 @@ impl<'map> ManiaPP<'map> {
let mut best_dist = f64::INFINITY;
let mut n3x0 = n_objects.saturating_sub(n320 + n300 + n200 + n50 + n_misses);

let max_left = n_remaining.saturating_sub(n200 + n50);

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

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(_), Some(_)) => {
(max_left.min(n320 + n300), max_left.min(n320 + n300))
}
(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 +376,19 @@ impl<'map> ManiaPP<'map> {
let mut best_dist = f64::INFINITY;
let mut n3x0 = n_objects.saturating_sub(n320 + n300 + n200 + n100 + n_misses);

let max_left = n_remaining.saturating_sub(n200 + n100);

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

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(_), Some(_)) => {
(max_left.min(n320 + n300), max_left.min(n320 + n300))
}
(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 @@ -421,17 +419,19 @@ impl<'map> ManiaPP<'map> {
let mut best_dist = f64::INFINITY;
let mut n3x0 = n_objects.saturating_sub(n320 + n300 + n200 + n_misses);

let max_left = n_remaining - n200;

let min_n3x0 = (((target_total - (2 * (n_remaining + n200)) as f64) / 4.0)
.floor() as usize)
.min(n_remaining - n200);
.min(max_left);

let max_n3x0 = (((target_total - (n_remaining + 3 * n200) as f64) / 5.0).ceil()
as usize)
.min(n_remaining - n200);
.min(max_left);

let (min_n3x0, max_n3x0) = match (self.n320, self.n300) {
(Some(_), Some(_)) => {
(n_remaining.min(n320 + n300), n_remaining.min(n320 + n300))
(max_left.min(n320 + n300), max_left.min(n320 + n300))
}
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
Expand Down Expand Up @@ -475,18 +475,20 @@ impl<'map> ManiaPP<'map> {
let mut best_dist = f64::INFINITY;
let mut n3x0 = n_objects.saturating_sub(n320 + n300 + n100 + n_misses);

let max_left = n_remaining - n100;

let min_n3x0 = ((acc * (3 * n_remaining) as f64
- (2 * n_remaining - n100) as f64)
.floor() as usize)
.min(n_remaining - n100);
.min(max_left);

let max_n3x0 = (((target_total - (n_remaining + n100) as f64) / 5.0).ceil()
as usize)
.min(n_remaining - n100);
.min(max_left);

let (min_n3x0, max_n3x0) = match (self.n320, self.n300) {
(Some(_), Some(_)) => {
(n_remaining.min(n320 + n300), n_remaining.min(n320 + n300))
(max_left.min(n320 + n300), max_left.min(n320 + n300))
}
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
Expand Down Expand Up @@ -531,17 +533,19 @@ impl<'map> ManiaPP<'map> {
let mut best_dist = f64::INFINITY;
let mut n3x0 = n_objects.saturating_sub(n320 + n300 + n50 + n_misses);

let max_left = n_remaining - n50;

let min_n3x0 = (((target_total - (4 * n_remaining - 3 * n50) as f64) / 2.0)
.floor() as usize)
.min(n_remaining - n50);
.min(max_left);

let max_n3x0 = (((target_total - (2 * n_remaining - n50) as f64) / 4.0).ceil()
as usize)
.min(n_remaining - n50);
.min(max_left);

let (min_n3x0, max_n3x0) = match (self.n320, self.n300) {
(Some(_), Some(_)) => {
(n_remaining.min(n320 + n300), n_remaining.min(n320 + n300))
(max_left.min(n320 + n300), max_left.min(n320 + n300))
}
(Some(_), None) => (min_n3x0.max(n320), max_n3x0.max(n320)),
(None, Some(_)) => (min_n3x0.max(n300), max_n3x0.max(n300)),
Expand Down

0 comments on commit 99e40e0

Please sign in to comment.