finished to implement the dynamic builder
This commit is contained in:
parent
c260404065
commit
e8102f0e72
2 changed files with 58 additions and 11 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue