Single path brute force
This commit is contained in:
parent
c10843ad2f
commit
2bc323aa58
4 changed files with 413 additions and 2 deletions
39
examples/brute_force.rs
Normal file
39
examples/brute_force.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use factorio_blueprint::{
|
||||
belt_finding::{
|
||||
brute_force::{Bruteforce, 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,
|
||||
};
|
||||
|
||||
b.apply_path_field(PathField::Belt {
|
||||
pos: Position::new(1, 0),
|
||||
dir: Direction::Down,
|
||||
});
|
||||
|
||||
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.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;
|
||||
|
||||
while b.next_finish_state() {
|
||||
println!("{}\n{}\n{}", b.count, b.solution_count, b);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue