@@ -8,9 +8,9 @@ pub struct RoverState {
88 pub pos : Coord ,
99 pub goal : Coord ,
1010 pub path : Vec < Coord > ,
11- pub obstacles : HashSet < Coord > , // Original fixed obstacles (gray)
12- pub dynamic_obstacles : Vec < Coord > , // User-added dynamic obstacles (yellow)
13- pub converted_obstacles : HashSet < Coord > , // Converted obstacles (blue)
11+ pub obstacles : HashSet < Coord > ,
12+ pub dynamic_obstacles : Vec < Coord > ,
13+ pub converted_obstacles : HashSet < Coord > ,
1414 pub algorithm : String ,
1515 pub speed : u32 ,
1616 pub width : usize ,
@@ -41,7 +41,6 @@ impl Rover {
4141 height,
4242 } ;
4343
44- // Start with empty grid
4544 let grid = vec ! [ vec![ false ; height] ; width] ;
4645 let pf: Box < dyn Pathfinder < Coord = Coord > > = Box :: new ( DStarLite :: new ( grid, start, goal) ) ;
4746
@@ -78,7 +77,6 @@ impl Rover {
7877 let grid = self . build_grid ( ) ;
7978 self . state . algorithm = algo. to_string ( ) ;
8079
81- // Rebuild pathfinder with current grid state
8280 self . pathfinder = match algo {
8381 "A*" => Box :: new ( AStar :: new ( grid, self . state . pos , self . state . goal ) ) ,
8482 "D*-Lite" => Box :: new ( DStarLite :: new ( grid, self . state . pos , self . state . goal ) ) ,
@@ -88,7 +86,6 @@ impl Rover {
8886 }
8987
9088 pub fn compute_path_now ( & mut self ) -> Vec < Coord > {
91- // Rebuild pathfinder with current obstacles
9289 let grid = self . build_grid ( ) ;
9390 self . pathfinder = match self . state . algorithm . as_str ( ) {
9491 "A*" => Box :: new ( AStar :: new ( grid, self . state . pos , self . state . goal ) ) ,
@@ -109,23 +106,18 @@ impl Rover {
109106 pub fn build_grid ( & self ) -> Vec < Vec < bool > > {
110107 let mut grid = vec ! [ vec![ false ; self . height] ; self . width] ;
111108
112- // Mark original static obstacles
113109 for & ( ox, oy) in & self . state . obstacles {
114110 if ox < self . width && oy < self . height {
115111 grid[ ox] [ oy] = true ;
116112 }
117113 }
118114
119- // Mark converted obstacles
120115 for & ( ox, oy) in & self . state . converted_obstacles {
121116 if ox < self . width && oy < self . height {
122117 grid[ ox] [ oy] = true ;
123118 }
124119 }
125120
126- // NOTE: dynamic_obstacles are NOT included in pathfinding grid
127- // They are only visual until converted
128-
129121 grid
130122 }
131123
0 commit comments