50 lines
1.4 KiB
Rust
50 lines
1.4 KiB
Rust
mod disease;
|
|
mod human;
|
|
mod population;
|
|
mod prelude {
|
|
pub use crate::disease::*;
|
|
pub use crate::human::*;
|
|
pub use crate::population::*;
|
|
pub use console::style;
|
|
pub use console::Term;
|
|
pub use rand::Rng;
|
|
pub const CORRECTED_PERCENTAGE: i32 = 101;
|
|
}
|
|
|
|
use prelude::*;
|
|
|
|
fn main() {
|
|
let term = Term::stdout();
|
|
term.write_line("********** Rusty Propagation (Console) 2022 **********")
|
|
.expect("Oops Looks like we have a problem here...");
|
|
term.write_line("Press any key to start the propagation")
|
|
.expect("Oops Looks like we have a problem here...");
|
|
|
|
let disease = Disease::new(20, 10, 5, String::from("Covid 44"));
|
|
let mut population = Population::new(20, 10, 5, 1000, 1000, disease);
|
|
//population.change_disease(disease);
|
|
println!("Before Filling");
|
|
//population.display();
|
|
population.generate();
|
|
println!("After Filling");
|
|
//population.display();
|
|
println!("After Propagation");
|
|
let mut stats: [i32; 4];
|
|
// = [0,0,0,0];
|
|
let mut counter: u32 = 0;
|
|
loop {
|
|
counter += 1;
|
|
stats = population.propagate();
|
|
//population.display();
|
|
println!(
|
|
"Normal: {} Infecteds: {} Immunes: {} Deads: {}",
|
|
stats[0], stats[1], stats[2], stats[3]
|
|
);
|
|
if stats[1] == 0 {
|
|
break;
|
|
}
|
|
}
|
|
println!("Propagation finished in {} steps", counter);
|
|
//population.display();
|
|
}
|