Initial conflict avoidance.
This commit is contained in:
parent
9751764611
commit
993fb0730c
4 changed files with 480 additions and 185 deletions
|
|
@ -1,57 +1,55 @@
|
|||
use factorio_blueprint::belt_finding::{common::Position, Problem};
|
||||
use clap::{Parser, ValueEnum};
|
||||
use factorio_blueprint::belt_finding::{conflict_avoidance::ConflictAvoidance, problems, Problem};
|
||||
|
||||
#[derive(ValueEnum, Clone)]
|
||||
enum Mode {
|
||||
Solve,
|
||||
ConflictAvoidance,
|
||||
}
|
||||
|
||||
#[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 mut p = Problem::new(17, 13);
|
||||
let args = Args::parse();
|
||||
|
||||
p.set_blocked(0, 3, true);
|
||||
let mut p = args.problem.get_problem();
|
||||
|
||||
p.set_blocked(1, 4, true);
|
||||
p.set_blocked(2, 4, true);
|
||||
p.set_blocked(1, 5, true);
|
||||
p.set_blocked(2, 5, true);
|
||||
|
||||
p.set_blocked(1, 7, true);
|
||||
p.set_blocked(2, 7, true);
|
||||
p.set_blocked(1, 8, true);
|
||||
p.set_blocked(2, 8, true);
|
||||
|
||||
p.set_blocked(0, 9, true);
|
||||
|
||||
p.set_blocked(16, 3, true);
|
||||
|
||||
p.set_blocked(14, 4, true);
|
||||
p.set_blocked(15, 4, true);
|
||||
p.set_blocked(14, 5, true);
|
||||
p.set_blocked(15, 5, true);
|
||||
|
||||
p.set_blocked(14, 7, true);
|
||||
p.set_blocked(15, 7, true);
|
||||
p.set_blocked(14, 8, true);
|
||||
p.set_blocked(15, 8, true);
|
||||
|
||||
p.set_blocked(16, 9, true);
|
||||
|
||||
p.add_connection(Position::new(3, 7), Position::new(13, 4));
|
||||
p.add_connection(Position::new(3, 8), Position::new(13, 5));
|
||||
|
||||
p.add_connection(Position::new(3, 4), Position::new(13, 8));
|
||||
p.add_connection(Position::new(3, 5), Position::new(13, 7));
|
||||
|
||||
// p.set_blocked(8, 12, true);
|
||||
// p.set_blocked(8, 11, true);
|
||||
// p.set_blocked(8, 10, true);
|
||||
// p.set_blocked(8, 9, true);
|
||||
// p.set_blocked(8, 8, true);
|
||||
// p.set_blocked(8, 7, true);
|
||||
// p.set_blocked(8, 6, true);
|
||||
// p.set_blocked(8, 5, true);
|
||||
// p.set_blocked(8, 4, true);
|
||||
// p.set_blocked(8, 3, true);
|
||||
// p.set_blocked(8, 2, true);
|
||||
// p.set_blocked(8, 1, true);
|
||||
// p.set_blocked(8, 0, true);
|
||||
|
||||
println!("{}", p);
|
||||
p.find_path();
|
||||
println!("{}", p);
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue