Skip to content

Commit 4cd98ee

Browse files
committed
don't convert to fixed point to find the max value of vectors of floats
1 parent 14d595a commit 4cd98ee

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,14 @@ fn main() {
385385
let foe_dmg: Vec<f32> = foe_turns.iter().map(|t| t.expected_damage(i)).collect();
386386
let mark_dmg: Vec<_> = mark_turns.iter().map(|h| h.breakeven(i)).collect();
387387

388-
let max_foe = foe_dmg.iter().map(|x| x.cmpable()).max().unwrap();
389-
let max_mark = mark_dmg.iter().map(|(x, _, _)| x.cmpable()).max().unwrap();
388+
let max_foe = foe_dmg.iter().fold(0.0_f32,|a ,b| b.max(a));
389+
let max_mark = mark_dmg.iter().fold(0.0_f32, |a, (b, _, _)| b.max(a));
390390

391391
for i in 0..foe_dmg.len() {
392392
// foe damage with marker for the max valued column
393393
print!(
394394
" | {}{:>width$.prec$}",
395-
if max_foe == foe_dmg[i].cmpable() {
395+
if max_foe == foe_dmg[i] {
396396
">"
397397
} else {
398398
" "
@@ -406,11 +406,11 @@ fn main() {
406406
if a different column is max foe (sign is positive), how much damage is
407407
increased over the max for damage
408408
*/
409-
if max_mark == mark_dmg[i].0.cmpable() {
410-
if max_foe == foe_dmg[i].cmpable() {
409+
if max_mark == mark_dmg[i].0 {
410+
if max_foe == foe_dmg[i] {
411411
print!(" {:>+width$.prec$}", mark_dmg[i].2);
412412
} else {
413-
print!(" {:>+width$.prec$}", mark_dmg[i].0 - uncmp(max_foe));
413+
print!(" {:>+width$.prec$}", mark_dmg[i].0 - max_foe);
414414
}
415415
} else {
416416
print!(" {:width$}", "");
@@ -421,7 +421,7 @@ fn main() {
421421
of a damage boost mark provides in subsequent rounds; and
422422
how many rounds it takes to offset the first round loss of
423423
bonus action attacks */
424-
if mark_dmg[i].0.cmpable() < max_foe {
424+
if mark_dmg[i].0 < max_foe {
425425
print!(" {:>width$} {0:1}", "");
426426
} else {
427427
print!(

0 commit comments

Comments
 (0)