finished to implement the dynamic builder

This commit is contained in:
JOLIMAITRE Matthieu 2022-05-30 15:29:07 +03:00
parent c260404065
commit e8102f0e72
2 changed files with 58 additions and 11 deletions

View file

@ -1,7 +1,7 @@
use std::str::FromStr;
use clap::Parser;
use labirust::{implementations::*, Executor};
use labirust::{implementations::*, Algorithm, Executor, SimpleGenerator};
enum Algorithms {
DepthFirst,
@ -22,16 +22,37 @@ impl FromStr for Algorithms {
#[derive(Parser)]
struct Parameters {
algorithm_kind: Algorithms,
/// Algorithm to use in the simulation.
/// One of: "depth-first", "breath-first"
algorithm: Algorithms,
/// Width of the maze to solve.
#[clap(short, default_value_t = 40)]
width: usize,
/// Height of the maze to solve.
#[clap(short, default_value_t = 20)]
height: usize,
/// Delay between two simulation ticks.
#[clap(short, default_value_t = 100)]
delay: usize,
}
fn main() {
let params = Parameters::parse();
let executor = todo!();
let algorithm: Box<dyn Algorithm> = match params.algorithm {
Algorithms::DepthFirst => Box::new(DepthFirst::new()),
Algorithms::BreathFirst => Box::new(BreathFirst::new()),
};
println!("Hello, world!");
let mut executor = Executor::build_dyn(algorithm, |b| {
b.generated(Box::new(SimpleGenerator::new(
params.width as isize,
params.height as isize,
)))
});
executor.run();
}