Refactor bruteforce interface

This commit is contained in:
hal8174 2023-12-11 20:23:32 +01:00
parent 2bc323aa58
commit 20073b88ce
2 changed files with 76 additions and 45 deletions

View file

@ -1,39 +1,24 @@
use factorio_blueprint::{
belt_finding::{
brute_force::{Bruteforce, PathField},
brute_force::{Bruteforce, BruteforceBuilder, PathField},
Direction, Position,
},
misc::Map,
};
fn main() {
let mut b = Bruteforce {
map: Map::new(5, 10),
path: vec![],
end_pos: Position::new(4, 9),
end_dir: Direction::Up,
count: 0,
solution_count: 0,
};
let mut b = BruteforceBuilder::new(6, 8);
b.apply_path_field(PathField::Belt {
pos: Position::new(1, 0),
dir: Direction::Down,
});
b.add_path(
(Position::new(1, 0), Direction::Down),
(Position::new(4, 6), Direction::Up),
);
b.map.get_mut(0, 2).blocked = true;
b.map.get_mut(1, 2).blocked = true;
b.map.get_mut(2, 2).blocked = true;
b.map.get_mut(3, 2).blocked = true;
b.map.get_mut(4, 2).blocked = true;
b.set_blocked_range(0, 2, 5, 5, true);
b.map.get_mut(0, 4).blocked = true;
b.map.get_mut(1, 4).blocked = true;
b.map.get_mut(2, 4).blocked = true;
b.map.get_mut(3, 4).blocked = true;
b.map.get_mut(4, 4).blocked = true;
let mut b = b.build();
while b.next_finish_state() {
println!("{}\n{}\n{}", b.count, b.solution_count, b);
println!("{}\n{}\n{}", b.count(), b.solution_count(), b);
}
}