forked from Maxluli/RustyPropagation
04a597c758
- comment out dead code - reduce number of casting - fix loop block
45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
mod human;
|
|
mod disease;
|
|
mod population;
|
|
mod prelude {
|
|
pub use crate::human::*;
|
|
pub use crate::disease::*;
|
|
pub use crate::population::*;
|
|
pub use rand::Rng;
|
|
pub use console::Term;
|
|
pub use console::style;
|
|
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,300,300,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!("Infecteds: {} Immunes: {} Deads: {}",stats[1],stats[2],stats[3]);
|
|
if stats[1] == 0 {break;}
|
|
}
|
|
println!("Propagation finished in {} steps",counter);
|
|
//population.display();
|
|
|
|
}
|