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::*; use clap::Parser; use std::time::Instant; #[derive(Parser, Debug)] struct Args { /// Display stats after each propagation #[clap(short, long)] display: bool, /// Width of humans grid in population #[clap(short, long, default_value_t = 1000)] width: i32, /// Height of humans grid in population #[clap(short, long, default_value_t = 1000)] height: i32, } fn main() { let args = Args::parse(); let term = Term::stdout(); term.write_line("********** Rusty Propagation (Console) 2022 **********") .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,args.width,args.height,disease); //population.change_disease(disease); println!("After Filling"); //population.display(); //population.display(); let mut stats: [i32; 4]; // = [0,0,0,0]; let mut counter: u32 = 0; let now = Instant::now(); loop { counter += 1; stats = population.propagate(); //population.display(); if args.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, now.elapsed()); //population.display(); }