Multi Path

This commit is contained in:
hal8174 2023-12-10 14:09:30 +01:00
parent 6f6a7f978b
commit c10843ad2f
3 changed files with 142 additions and 34 deletions

View file

@ -1,7 +1,7 @@
use factorio_blueprint::belt_finding::{Position, Problem};
fn main() {
let mut p = Problem::new(17, 13, Position::new(3, 8), Position::new(13, 5));
let mut p = Problem::new(17, 13);
p.set_blocked(0, 3, true);
@ -31,9 +31,27 @@ fn main() {
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);
}

32
examples/solve_belt2.rs Normal file
View file

@ -0,0 +1,32 @@
use factorio_blueprint::belt_finding::{Position, Problem};
fn main() {
let mut p = Problem::new(33, 13);
p.set_blocked_range(1, 3, 2, 5, true);
p.set_blocked_range(1, 7, 2, 9, true);
p.set_blocked(0, 3, true);
p.set_blocked(0, 8, true);
p.set_blocked_range(10, 0, 21, 2, true);
p.set_blocked_range(10, 5, 21, 7, true);
p.set_blocked_range(10, 10, 21, 12, true);
p.set_blocked_range(30, 3, 31, 5, true);
p.set_blocked_range(30, 7, 31, 9, true);
p.set_blocked(32, 3, true);
p.set_blocked(32, 9, true);
p.add_connection(Position::new(3, 3), Position::new(29, 7));
p.add_connection(Position::new(3, 4), Position::new(29, 9));
p.add_connection(Position::new(3, 5), Position::new(29, 8));
p.add_connection(Position::new(3, 7), Position::new(29, 3));
p.add_connection(Position::new(3, 8), Position::new(29, 5));
p.add_connection(Position::new(3, 9), Position::new(29, 4));
println!("{p}");
p.find_path();
println!("{p}");
}