Corrected some display and a nasty but in rmax reporting

This commit is contained in:
Dandaedre 2025-02-25 03:05:00 +01:00
parent 18c864efe5
commit b6de1aa1cd
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
4 changed files with 105 additions and 29 deletions

View File

@ -59,7 +59,7 @@ macro_rules! add_field_to_chart {
let $chart = $chart
.series(
charming::series::Line::new()
.stack("Total")
// .stack("Total")
.data($table_names)
.name(stringify!($table_names))
.mark_point(charming::element::MarkPoint::new().data(vec![("max", "Max"), ("min", "Min")]))
@ -68,7 +68,6 @@ macro_rules! add_field_to_chart {
.type_(charming::element::MarkLineDataType::Average)
.name("Avg"),
)])),
);
)*

View File

@ -146,9 +146,11 @@ impl ToAnalysis for RefinedEquipementList {
expected_armor_break_per_attack # f64,
avg_damage_2a_safe # f64,
avg_damage_single_huge_hit # f64,
speed # f64,
// speed # f64,
variance # f64,
variance_pct # f64,
scenario_damage # f64,
defensive # f64,
// defensive # f64,
earlygame_sustained_damage_per_turn # f64,
midgame_sustained_damage_per_turn # f64,
endgame_sustained_damage_per_turn # f64,
@ -161,9 +163,11 @@ impl ToAnalysis for RefinedEquipementList {
round!(ref_equipement.advanced.expected_armor_break_per_attack ),
round!(ref_equipement.advanced.avg_damage_2a_safe ),
round!(ref_equipement.advanced.avg_damage_single_huge_hit ),
round!(ref_equipement.advanced.speed ),
// round!(ref_equipement.advanced.speed),
round!(ref_equipement.advanced.variance),
round!(ref_equipement.advanced.variance_pct ),
round!(ref_equipement.advanced.scenario_damage ),
round!(ref_equipement.advanced.defensive ),
// round!(ref_equipement.advanced.defensive ),
round!(ref_equipement.advanced.earlygame_sustained_damage_per_turn ),
round!(ref_equipement.advanced.midgame_sustained_damage_per_turn ),
round!(ref_equipement.advanced.endgame_sustained_damage_per_turn ),
@ -229,14 +233,18 @@ pub struct AdvancedStats {
pub midgame_sustained_damage_per_turn: f64,
/// The sustained damage of an endgame character, normalized over 10 turns
pub endgame_sustained_damage_per_turn: f64,
/// The damage variance between the base damage and the potential damage
pub variance: f64,
/// This same variance as a percent
pub variance_pct: f64,
// QOL Metrics
}
impl From<&InnerEquipementStats> for AdvancedStats {
fn from(value: &InnerEquipementStats) -> Self {
let max_damage_per_attack =
(value.damage + value.p_damage * (value.rmax.saturating_sub(1))) as f64;
let max_damage_per_attack = (value.damage + value.p_damage * (value.rmax)) as f64;
let armor_break_per_attack =
(value.armor_break as f64 + value.antimaterial as f64).min(max_damage_per_attack);
let variance = (value.p_damage * value.rmax) as f64;
Self {
display_name: value.name.join(" "),
max_damage_per_attack,
@ -249,6 +257,8 @@ impl From<&InnerEquipementStats> for AdvancedStats {
/ value.action_cost as f64,
scenario_damage: get_damage_with_simulation(value, Actions(4), Attacks(2)),
defensive: (value.parry as f64).max(value.dodge.into()),
variance,
variance_pct: variance / value.damage as f64,
avg_damage_2a_safe: BestDamageScenarios::from_action_constraints(
value,
Actions(2),

View File

@ -27,20 +27,80 @@ pub(super) fn get_damage_with_simulation(
actions: Actions,
attacks: Attacks,
) -> f64 {
let turns = &[
(actions, attacks, Dices(0), Precision(0)),
(actions, attacks, Dices(12), Precision(13)),
(actions, attacks, Dices(12), Precision(13)),
(actions, attacks, Dices(5), Precision(5)),
(actions, attacks, Dices(7), Precision(8)),
(actions, attacks, Dices(7), Precision(9)),
(actions, attacks, Dices(7), Precision(9)),
(actions, attacks, Dices(7), Precision(9)),
(actions, attacks, Dices(7), Precision(9)),
(actions, attacks, Dices(7), Precision(9)),
let mut turns = vec![
TurnInfo {
actions: Actions(0),
attacks: Attacks(0),
dices: Dices(0),
precision: Precision(0),
},
TurnInfo {
actions,
attacks,
dices: Dices(12),
precision: Precision(13),
},
TurnInfo {
actions,
attacks,
dices: Dices(12),
precision: Precision(13),
},
TurnInfo {
actions,
attacks: attacks - Attacks(1),
dices: Dices(5),
precision: Precision(5),
},
TurnInfo {
actions,
attacks: attacks - Attacks(1),
dices: Dices(5),
precision: Precision(5),
},
// Cuck turn
TurnInfo {
actions,
attacks,
dices: Dices(7),
precision: Precision(9),
},
TurnInfo {
actions,
attacks,
dices: Dices(7),
precision: Precision(9),
},
TurnInfo {
actions,
attacks,
dices: Dices(7),
precision: Precision(9),
},
TurnInfo {
actions,
attacks,
dices: Dices(7),
precision: Precision(9),
},
];
if value.speed >= 0 {
turns.push(TurnInfo {
actions,
attacks,
dices: Dices(6),
precision: Precision(5),
});
} else {
turns.push(TurnInfo {
actions: Actions(1),
attacks: Attacks(1),
dices: Dices(6),
precision: Precision(5),
});
}
0.
damage_over_turns(value, &turns) / 10.
}
/// Sustained damage
@ -62,8 +122,7 @@ pub(super) fn get_sustained_damage(
dices,
precision,
}; 10];
let total_damage = damage_over_turns(value, l);
total_damage / 10.
damage_over_turns(value, l) / 10.
// Iterate 10 turns, every turn we need to substract the leftover reloading
// value.damage.into()
}
@ -285,8 +344,8 @@ pub(super) fn binomial_dice_distribution(
(equipement.damage as f64
+ equipement.p_damage as f64
* (target_dices
.clamp(0, equipement.rmax as usize)
.saturating_sub(1)) as f64)
.saturating_sub(1)
.clamp(0, equipement.rmax as usize)) as f64)
* probability_success
} else {
0.
@ -329,7 +388,7 @@ mod test {
damage: 10,
p_damage: 2,
precision: 0,
rmax: 3,
rmax: 2,
armor_break: 2,
..Default::default()
}
@ -337,6 +396,7 @@ mod test {
macro_rules! assert_close {
($a:expr, $b:expr) => {
println!("{} ~= {}", $a, $b);
assert!(($a - $b).abs() < 1E-3);
};
}
@ -363,7 +423,7 @@ mod test {
let eq = new_inner_eq();
assert_close!(
average_damage(&eq, &[Precision(9)], &[Dices(9)]),
13.99995162
13.999999999
);
assert_close!(
average_damage(&eq, &[Precision(4)], &[Dices(4)]),
@ -377,7 +437,7 @@ mod test {
damage: 10,
p_damage: 2,
precision: 0,
rmax: 3,
rmax: 2,
action_cost: 1,
..Default::default()
};
@ -385,7 +445,7 @@ mod test {
damage: 10,
p_damage: 2,
precision: 0,
rmax: 3,
rmax: 2,
action_cost: 2,
..Default::default()
};
@ -393,7 +453,7 @@ mod test {
damage: 10,
p_damage: 2,
precision: 0,
rmax: 3,
rmax: 2,
action_cost: 2,
reload_cost: Some(2),
..Default::default()

View File

@ -26,6 +26,13 @@ impl Add for Attacks {
Self(self.0 + rhs.0)
}
}
impl Sub for Attacks {
type Output = Self;
fn sub(self, rhs: Self) -> Self::Output {
Self(self.0 - rhs.0)
}
}
impl std::ops::Deref for Attacks {
type Target = i8;