configurable width & height
This commit is contained in:
+26
-6
@@ -12,14 +12,31 @@ mod prelude {
|
||||
}
|
||||
|
||||
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, 1000, 1000, disease);
|
||||
let mut population = Population::new(20,10,5,args.width,args.height,disease);
|
||||
//population.change_disease(disease);
|
||||
println!("After Filling");
|
||||
//population.display();
|
||||
@@ -27,18 +44,21 @@ fn main() {
|
||||
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();
|
||||
println!(
|
||||
"Normal: {} Infecteds: {} Immunes: {} Deads: {}",
|
||||
stats[0], stats[1], stats[2], stats[3]
|
||||
);
|
||||
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);
|
||||
println!("Propagation finished in {} steps, {:?}", counter, now.elapsed());
|
||||
//population.display();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user