Change initial pathfinding.
This commit is contained in:
parent
73c525985c
commit
f25b58448e
5 changed files with 254 additions and 186 deletions
|
|
@ -69,6 +69,7 @@ impl ConflictAvoidance {
|
|||
}
|
||||
let mut belts = Vec::new();
|
||||
for i in 0..problem.path.len() {
|
||||
dbg!(&problem.path[i]);
|
||||
let mut p = Vec::new();
|
||||
|
||||
p.push(PathField::Belt {
|
||||
|
|
@ -76,22 +77,34 @@ impl ConflictAvoidance {
|
|||
dir: problem.start[i].1,
|
||||
});
|
||||
|
||||
for j in 0..problem.path[i].len() - 1 {
|
||||
p.push(PathField::Belt {
|
||||
pos: problem.path[i][j],
|
||||
dir: Direction::from_neighbors(&problem.path[i][j], &problem.path[i][j + 1]),
|
||||
});
|
||||
for (pos, dir) in &problem.path[i][1..] {
|
||||
let start = p.last().unwrap().end_pos();
|
||||
let start = start.0.in_direction(&start.1, 1);
|
||||
dbg!(start, pos);
|
||||
if &start == pos {
|
||||
p.push(PathField::Belt {
|
||||
pos: *pos,
|
||||
dir: *dir,
|
||||
});
|
||||
} else {
|
||||
p.push(PathField::Underground {
|
||||
pos: start,
|
||||
dir: *dir,
|
||||
len: u8::max((start.x - pos.x).abs() as u8, (start.y - pos.y).abs() as u8),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
p.push(PathField::Belt {
|
||||
pos: *problem.path[i].last().unwrap(),
|
||||
dir: problem.end[i].1,
|
||||
});
|
||||
// p.push(PathField::Belt {
|
||||
// pos: *problem.path[i].last().unwrap(),
|
||||
// dir: problem.end[i].1,
|
||||
// });
|
||||
|
||||
// p.push(PathField::Belt {
|
||||
// pos: problem.end[i].0,
|
||||
// dir: problem.end[i].1,
|
||||
// });
|
||||
dbg!(&p);
|
||||
|
||||
belts.push(p);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue