You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
use kartsimrust::{
|
|
combat::make_them_fight,
|
|
premade::{get_bob, get_drub},
|
|
};
|
|
|
|
fn main() {
|
|
let mut a = 1.0;
|
|
let mut b = 1.0;
|
|
|
|
let mut total_turns = 0.0;
|
|
let mut battles = 0.0;
|
|
|
|
loop {
|
|
let mut bob = get_bob();
|
|
|
|
let mut drub = get_drub();
|
|
let mut drub2 = get_drub();
|
|
|
|
if let Some(turns) = make_them_fight(vec![&mut bob], vec![&mut drub, &mut drub2]) {
|
|
battles += 1.0;
|
|
total_turns += turns as f64;
|
|
|
|
if bob.hp <= 0 {
|
|
b += 1.0;
|
|
println!("Bob died in {} turns.", turns)
|
|
} else {
|
|
a += 1.0;
|
|
println!("Drub died in {} turns.", turns)
|
|
}
|
|
|
|
if (a * b) / (f64::powi(a + b, 2) * (a + b + 1.0)) <= 0.00001 {
|
|
break;
|
|
}
|
|
} else {
|
|
println!("No one died.")
|
|
}
|
|
}
|
|
println!(
|
|
"Bob won {:.2}% of battles in an average of {:.1} turns.",
|
|
a / (a + b) * 100.0,
|
|
total_turns / battles
|
|
)
|
|
}
|