Fix warnings.

This commit is contained in:
hal8174 2024-03-23 23:52:46 +01:00
parent 8c29cb1e53
commit 1596bf180d
8 changed files with 54 additions and 71 deletions

View file

@ -76,7 +76,7 @@ impl ConflictAvoidance {
}
let mut belts = Vec::new();
for i in 0..problem.path.len() {
dbg!(&problem.path[i]);
// dbg!(&problem.path[i]);
let mut p = Vec::new();
p.push(PathField::Belt {
@ -87,7 +87,7 @@ impl ConflictAvoidance {
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);
// dbg!(start, pos);
if &start == pos {
p.push(PathField::Belt {
pos: *pos,
@ -97,7 +97,10 @@ impl ConflictAvoidance {
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),
len: u8::max(
(start.x - pos.x).unsigned_abs() as u8,
(start.y - pos.y).unsigned_abs() as u8,
),
})
}
}
@ -111,7 +114,6 @@ impl ConflictAvoidance {
// pos: problem.end[i].0,
// dir: problem.end[i].1,
// });
dbg!(&p);
belts.push(p);
}
@ -157,7 +159,7 @@ impl ConflictAvoidance {
let mut mapping = Vec::new();
let offset = Position::new(*xrange.start() as i32 - 1, *yrange.start() as i32 - 1);
dbg!(&xrange, &yrange);
// dbg!(&xrange, &yrange);
for (i, path) in self.belts.iter().enumerate() {
// index of first PathField where the next position is in the area
@ -181,8 +183,6 @@ impl ConflictAvoidance {
})
.map(|rev_i| path.len() - rev_i - 1);
dbg!(start_index, end_index);
if let Some((start_index, end_index)) = Option::zip(start_index, end_index) {
// dbg!(start_index, end_index, path[start_index], path[end_index]);
@ -268,7 +268,7 @@ impl ConflictAvoidance {
Some(
mapping
.into_iter()
.zip(solutions.into_iter())
.zip(solutions)
.map(|((path_id, start, end), path)| BruteForceEntry {
path_id,
start,
@ -305,16 +305,16 @@ impl ConflictAvoidance {
}
}
for y in 0..self.map.height {
for x in 0..self.map.width {
if *conflicts.get(x, y) > 1 {
print!("#");
} else {
print!(" ");
}
}
println!();
}
// for y in 0..self.map.height {
// for x in 0..self.map.width {
// if *conflicts.get(x, y) > 1 {
// print!("#");
// } else {
// print!(" ");
// }
// }
// println!();
// }
let mut candidates = Vec::new();
@ -506,7 +506,7 @@ impl ConflictAvoidance {
}
// Print body
print_map(self.map.width as i32, self.map.height as i32, |x, y| {
let _ = print_map(self.map.width as i32, self.map.height as i32, |x, y| {
let mut color = ColorSpec::new();
if let Some((xrange, yrange)) = &self.range {