Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseEmond committed Oct 5, 2024
1 parent 239c202 commit 8675454
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
22 changes: 22 additions & 0 deletions bot/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,25 @@ pub fn make_grid(rows: Vec<&str>) -> Grid {
}
Grid::new(width as u8, height as u8, tiles)
}

#[allow(dead_code)]
fn debug_print(grid: &Grid, highlights: Vec<(&Pos, char)>) {
for y in 0..(grid.height as i16) {
for x in 0..(grid.width as i16) {
let pos = Pos { x, y };
let highlight = highlights.iter()
.filter(|(&p, _)| p == pos)
.map(|(_, c)| c)
.next();
if let Some(c) = highlight {
print!("{}", c);
} else if grid.is_empty(&pos) {
print!(" ");
} else {
print!("#");
}
}
println!();
}
}

8 changes: 4 additions & 4 deletions bot/src/pathfinding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl PathfinderState {

/// Get cost of going to 'to', from our start position.
/// Only valid after using a 'Pathfinder'.
#[allow(dead_code)]
pub fn get_cost(&self, grid: &Grid, to: &Pos) -> Cost {
self.cost[grid.empty_tile_idx(to)]
}
Expand Down Expand Up @@ -74,7 +75,6 @@ trait Pathfinder {
self.commit();
while let Some(pos_idx) = self.next_node(&state) {
let current_cost = state.cost[pos_idx];
let pos = grid.empty_tiles[pos_idx];
// Note: order is irrelevant, since we enforce order in the
// pathfinder implementations to match the JS behavior anyway.
for next_pos_idx in grid.get_neighbors(pos_idx) {
Expand Down Expand Up @@ -105,6 +105,7 @@ struct SlowAggressivePathfinder {
}

impl SlowAggressivePathfinder {
#[allow(dead_code)]
fn new(grid: &Grid) -> Self {
Self { unseen: (0..grid.empty_tiles.len()).collect() }
}
Expand Down Expand Up @@ -147,7 +148,7 @@ struct FastAggressivePathfinder {
}

impl FastAggressivePathfinder {
fn new(grid: &Grid) -> Self {
fn new(_grid: &Grid) -> Self {
Self {
frontier: VecDeque::new(),
frontier_cost: 0,
Expand All @@ -174,7 +175,7 @@ impl Pathfinder for FastAggressivePathfinder {
node
}

fn queue(&mut self, state: &PathfinderState, next: Node, cost: Cost) {
fn queue(&mut self, _state: &PathfinderState, next: Node, cost: Cost) {
assert!(cost == self.frontier_cost || cost == self.frontier_cost + 1);
if cost == self.frontier_cost {
self.frontier_buffer.push(next);
Expand Down Expand Up @@ -275,7 +276,6 @@ mod tests {
while let Some(pos_idx) = fast.next_node(&state) {
assert_eq!(Some(pos_idx), slow.next_node(&state));
let current_cost = state.cost[pos_idx];
let pos = grid.empty_tiles[pos_idx];
for next_pos_idx in grid.get_neighbors(pos_idx) {
let prev_cost = state.cost[next_pos_idx];
let new_cost = current_cost + 1;
Expand Down
21 changes: 0 additions & 21 deletions bot/src/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,27 +337,6 @@ impl State {

}

#[allow(dead_code)]
fn debug_print(grid: &Grid, highlights: Vec<(&Pos, char)>) {
for y in 0..(grid.height as i16) {
for x in 0..(grid.width as i16) {
let pos = Pos { x, y };
let highlight = highlights.iter()
.filter(|(&p, _)| p == pos)
.map(|(_, c)| c)
.next();
if let Some(c) = highlight {
print!("{}", c);
} else if grid.is_empty(&pos) {
print!(" ");
} else {
print!("#");
}
}
println!();
}
}

#[cfg(test)]
mod tests {
use strum::IntoEnumIterator;
Expand Down

0 comments on commit 8675454

Please sign in to comment.