Changed bruteforce end pos.
This commit is contained in:
parent
7fdf32342a
commit
2bf648f657
2 changed files with 95 additions and 49 deletions
|
|
@ -225,11 +225,7 @@ impl ConflictAvoidance {
|
|||
|
||||
// edge cases with underground into and end
|
||||
|
||||
if let Some(PathField::Underground {
|
||||
pos,
|
||||
dir: _,
|
||||
len: _,
|
||||
}) = path.get(end_index + 1)
|
||||
if let Some(PathField::Underground { pos, dir, len }) = path.get(end_index + 1)
|
||||
{
|
||||
if xrange.contains(&(pos.x as usize)) && yrange.contains(&(pos.y as usize))
|
||||
{
|
||||
|
|
@ -237,9 +233,38 @@ impl ConflictAvoidance {
|
|||
println!("Blocked {:?}", p);
|
||||
b.set_blocked(p.x as usize, p.y as usize, true);
|
||||
}
|
||||
|
||||
for l in 1..*len {
|
||||
let p = pos.in_direction(dir, l as i32);
|
||||
|
||||
if xrange.contains(&(p.x as usize)) && yrange.contains(&(p.y as usize))
|
||||
{
|
||||
let p = p - offset;
|
||||
b.set_underground(p.x as usize, p.y as usize, Some(*dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b.add_path((start_pos - offset, start_dir), (end_pos - offset, end_dir));
|
||||
let start_pos_offset = start_pos - offset;
|
||||
b.set_blocked(
|
||||
start_pos_offset.x as usize,
|
||||
start_pos_offset.y as usize,
|
||||
true,
|
||||
);
|
||||
|
||||
if let PathField::Underground { pos, dir, len } = path[start_index] {
|
||||
for l in 1..len {
|
||||
let p = pos.in_direction(&dir, l as i32);
|
||||
|
||||
if xrange.contains(&(p.x as usize)) && yrange.contains(&(p.y as usize))
|
||||
{
|
||||
let p = p - offset;
|
||||
b.set_underground(p.x as usize, p.y as usize, Some(dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b.add_path((start_pos_offset, start_dir), (end_pos - offset, end_dir));
|
||||
|
||||
mapping.push((i, start_index, end_index));
|
||||
}
|
||||
|
|
@ -249,6 +274,7 @@ impl ConflictAvoidance {
|
|||
|
||||
let mut b = b.build();
|
||||
|
||||
println!("{}", b);
|
||||
println!("{}", self);
|
||||
|
||||
let mut min_cost = f64::INFINITY;
|
||||
|
|
@ -274,14 +300,7 @@ impl ConflictAvoidance {
|
|||
|
||||
t.extend_from_slice(&self.belts[index][0..=start]);
|
||||
t.extend(p[1..].iter().map(|p| p.offset(&offset)));
|
||||
let (end_pos, end_dir) = self.belts[index][end].end_pos();
|
||||
t.push(PathField::Belt {
|
||||
pos: end_pos,
|
||||
dir: end_dir,
|
||||
});
|
||||
if end + 1 < self.belts[index].len() {
|
||||
t.extend_from_slice(&self.belts[index][end + 1..]);
|
||||
}
|
||||
t.extend_from_slice(&self.belts[index][end + 1..]);
|
||||
// println!("{:?}", &t);
|
||||
// println!();
|
||||
// println!("{:?}", &self.belts[index]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue