Bug fixes
This commit is contained in:
parent
a11b39cf9f
commit
f20a1841c9
6 changed files with 75 additions and 25 deletions
|
|
@ -213,12 +213,16 @@ impl ConflictAvoidance {
|
|||
}
|
||||
}
|
||||
|
||||
let start_pos_offset = start_pos - offset;
|
||||
b.set_blocked(
|
||||
start_pos_offset.x as usize,
|
||||
start_pos_offset.y as usize,
|
||||
true,
|
||||
);
|
||||
if xrange.contains(&(start_pos.x as usize))
|
||||
&& yrange.contains(&(start_pos.y as usize))
|
||||
{
|
||||
let p = start_pos - offset;
|
||||
// println!("Blocked {:?}", p);
|
||||
if b.get_blocked(p.x as usize, p.y as usize) {
|
||||
return None;
|
||||
}
|
||||
b.set_blocked(p.x as usize, p.y as usize, true);
|
||||
}
|
||||
|
||||
if let PathField::Underground { pos, dir, len } = path[start_index] {
|
||||
for l in 1..len {
|
||||
|
|
@ -231,6 +235,7 @@ impl ConflictAvoidance {
|
|||
}
|
||||
}
|
||||
|
||||
let start_pos_offset = start_pos - offset;
|
||||
b.add_path((start_pos_offset, start_dir), (end_pos - offset, end_dir));
|
||||
|
||||
mapping.push((i, start_index, end_index));
|
||||
|
|
@ -255,6 +260,7 @@ impl ConflictAvoidance {
|
|||
|
||||
while b.next_finish_state() {
|
||||
// println!("{}", b);
|
||||
// b.print();
|
||||
let c = b.cost();
|
||||
if c < min_cost {
|
||||
min_cost = c;
|
||||
|
|
@ -363,6 +369,7 @@ impl ConflictAvoidance {
|
|||
let yrange = c.min.y as usize..=c.max.y as usize;
|
||||
let offset = Position::new(*xrange.start() as i32 - 1, *yrange.start() as i32 - 1);
|
||||
if let Some(r) = result {
|
||||
// println!("Here");
|
||||
for BruteForceEntry {
|
||||
path_id,
|
||||
start,
|
||||
|
|
@ -454,6 +461,32 @@ impl ConflictAvoidance {
|
|||
}
|
||||
}
|
||||
|
||||
for path in &self.belts {
|
||||
for p in &path[1..] {
|
||||
match p {
|
||||
PathField::Belt { pos, dir: _ } => {
|
||||
if conflicts.get(pos.x as usize, pos.y as usize) == &true {
|
||||
return false;
|
||||
} else {
|
||||
conflicts.set(pos.x as usize, pos.y as usize, true);
|
||||
}
|
||||
}
|
||||
PathField::Underground { pos, dir, len } => {
|
||||
if conflicts.get(pos.x as usize, pos.y as usize) == &true {
|
||||
return false;
|
||||
} else {
|
||||
conflicts.set(pos.x as usize, pos.y as usize, true);
|
||||
}
|
||||
let end = pos.in_direction(dir, *len as PositionType);
|
||||
if conflicts.get(end.x as usize, end.y as usize) == &true {
|
||||
return false;
|
||||
} else {
|
||||
conflicts.set(end.x as usize, end.y as usize, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue