Add direction to beltfinding.

This commit is contained in:
hal8174 2024-02-27 17:50:02 +01:00
parent 29ef8eb39d
commit 0b84841768
2 changed files with 164 additions and 49 deletions

View file

@ -71,6 +71,11 @@ impl ConflictAvoidance {
for i in 0..problem.path.len() {
let mut p = Vec::new();
p.push(PathField::Belt {
pos: problem.start[i].0,
dir: problem.start[i].1,
});
for j in 0..problem.path[i].len() - 1 {
p.push(PathField::Belt {
pos: problem.path[i][j],
@ -80,7 +85,12 @@ impl ConflictAvoidance {
p.push(PathField::Belt {
pos: *problem.path[i].last().unwrap(),
dir: *p.last().unwrap().dir(),
dir: problem.end[i].1,
});
p.push(PathField::Belt {
pos: problem.end[i].0,
dir: problem.end[i].1,
});
belts.push(p);
@ -109,7 +119,7 @@ impl ConflictAvoidance {
}
for path in &self.belts {
for p in path {
for p in &path[1..path.len() - 1] {
match p {
PathField::Belt { pos, dir: _ } => {
*conflicts.get_mut(pos.x as usize, pos.y as usize) += 1
@ -426,7 +436,7 @@ impl ConflictAvoidance {
}
for path in &self.belts {
for p in path {
for p in &path[1..path.len() - 1] {
match p {
PathField::Belt { pos, dir: _ } => {
*conflicts.get_mut(pos.x as usize, pos.y as usize) += 1