70 lines
1.6 KiB
Rust
70 lines
1.6 KiB
Rust
use std::io;
|
|
|
|
use clap::{Parser, ValueEnum};
|
|
use factorio_blueprint::belt_finding::{conflict_avoidance::ConflictAvoidance, problems, Problem};
|
|
|
|
#[derive(ValueEnum, Clone)]
|
|
enum Mode {
|
|
Solve,
|
|
ConflictAvoidance,
|
|
ConflictStep,
|
|
}
|
|
|
|
#[derive(ValueEnum, Clone)]
|
|
enum ProblemCase {
|
|
Level1,
|
|
Level2,
|
|
}
|
|
|
|
impl ProblemCase {
|
|
fn get_problem(&self) -> Problem {
|
|
match self {
|
|
ProblemCase::Level1 => problems::belt_madness_level_1(),
|
|
ProblemCase::Level2 => problems::belt_madness_level_2(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Parser)]
|
|
struct Args {
|
|
#[arg(value_enum, default_value = "level1")]
|
|
problem: ProblemCase,
|
|
#[arg(value_enum, default_value = "solve")]
|
|
mode: Mode,
|
|
}
|
|
|
|
fn main() {
|
|
let args = Args::parse();
|
|
|
|
let mut p = args.problem.get_problem();
|
|
|
|
match args.mode {
|
|
Mode::Solve => {
|
|
println!("{}", p);
|
|
p.find_path();
|
|
println!("{}", p);
|
|
}
|
|
Mode::ConflictAvoidance => {
|
|
println!("{}", p);
|
|
p.find_path();
|
|
println!("{}", p);
|
|
let mut c = ConflictAvoidance::new(p);
|
|
println!("{}", c);
|
|
while c.remove_conflict() {
|
|
println!("{}", c)
|
|
}
|
|
}
|
|
Mode::ConflictStep => {
|
|
println!("{}", p);
|
|
p.find_path();
|
|
println!("{}", p);
|
|
let mut c = ConflictAvoidance::new(p);
|
|
println!("{}", c);
|
|
while c.remove_conflict() {
|
|
println!("{}", c);
|
|
let mut s = String::new();
|
|
let _ = io::stdin().read_line(&mut s);
|
|
}
|
|
}
|
|
}
|
|
}
|