diff --git a/src/simulator/crates/mc-turn/src/courier_resolver.rs b/src/simulator/crates/mc-turn/src/courier_resolver.rs index 908c406d..d65ca3a3 100644 --- a/src/simulator/crates/mc-turn/src/courier_resolver.rs +++ b/src/simulator/crates/mc-turn/src/courier_resolver.rs @@ -97,7 +97,7 @@ pub fn astar_path( era_tier: u8, ) -> Option> { let grid = state.grid.as_ref()?; - let (w, h) = (grid.width, grid.height); + let (grid_w, grid_h) = (grid.width, grid.height); if start == goal { return Some(vec![start]); @@ -109,8 +109,8 @@ pub fn astar_path( let mut came_from: HashMap<(i32, i32), (i32, i32)> = HashMap::new(); g_cost.insert(start, 0); - let h = hex_dist(start, goal); - open.push(Reverse((h, 0, start))); + let h0 = hex_dist(start, goal); + open.push(Reverse((h0, 0, start))); while let Some(Reverse((_, g, pos))) = open.pop() { if pos == goal { @@ -120,7 +120,7 @@ pub fn astar_path( if g > *g_cost.get(&pos).unwrap_or(&u32::MAX) { continue; } - for neighbor in offset_neighbors(pos.0, pos.1, w, h) { + for neighbor in offset_neighbors(pos.0, pos.1, grid_w, grid_h) { let step_cost = match tile_cost(state, neighbor.0, neighbor.1, era_tier) { Some(c) => c, None => continue, // impassable @@ -299,6 +299,7 @@ impl<'a> CourierMapView for GameStateMapView<'a> { #[cfg(test)] mod tests { use super::*; + use rand::RngCore; use mc_trade::{ CourierRoute, DiplomacyEvent, DiplomaticAgreement, SharedMapAgreement, TradeLedger, step_shared_map_agreements, diff --git a/src/simulator/crates/mc-turn/src/formation_move.rs b/src/simulator/crates/mc-turn/src/formation_move.rs index 9db82286..bd53f393 100644 --- a/src/simulator/crates/mc-turn/src/formation_move.rs +++ b/src/simulator/crates/mc-turn/src/formation_move.rs @@ -458,6 +458,7 @@ mod tests { pending_formation_shapes: vec![], pending_split_requests: vec![], pending_auto_join_requests: vec![], + ..Default::default() }; let unit_ids = vec![10u32, 11, 12]; let positions = vec![(0i32, 0i32), (0, 1), (0, -1)];