fn build(&mut self, map: &Map) {
        let mapsize: usize = (self.size_x * self.size_y) as usize;
        let mut open_list: VecDeque<((usize, usize), f32)> = VecDeque::with_capacity(mapsize);

        if let Some(pos) = map.starting_point {
            open_list.push_back(((pos.x, pos.y), 0.0));
            let idx = self.xy_idx(pos.x, pos.y);
            self.tiles[idx] = 0.0;
        }

        while let Some(((x, y), depth)) = open_list.pop_front() {
            let exits = map.get_available_exits(x, y);
            for (x, y, add_depth) in exits {
                let idx = self.xy_idx(x, y);
                let new_depth = depth + add_depth;
                let prev_depth = self.tiles[idx];
                if new_depth >= prev_depth { continue; }
                if new_depth >= self.max_depth { continue; }
                self.tiles[idx] = new_depth;
                open_list.push_back(((x, y), new_depth));
            }
        }
    }
/// Builds the Dijkstra map: iterate from each starting point, to each exit provided by BaseMap's
/// exits implementation. Each step adds cost to the current depth, and is discarded if the new
/// depth is further than the current depth.
/// WARNING: Will give incorrect results when used with non-uniform exit costs. Much slower
/// algorithm required to support that.
Builds the Dijkstra map: iterate from each starting point, to each exit provided by BaseMap's
exits implementation. Each step adds cost to the current depth, and is discarded if the new
depth is further than the current depth.
WARNING: Will give incorrect results when used with non-uniform exit costs. Much slower
algorithm required to support that.
Builds the Dijkstra map : iterate from each starting point to each exit provided by BaseMap ' s exits implementation . Each step adds cost to the current depth and is discarded if the new depth is further than the current depth . WARNING : Will give incorrect results when used with non - uniform exit costs . Much slower algorithm required to support that .
fn build(&mut self, map: &Map) {
        let mapsize: usize = (self.size_x * self.size_y) as usize;
        let mut open_list: VecDeque<((usize, usize), f32)> = VecDeque::with_capacity(mapsize);
        if let Some(pos) = map.starting_point {
            open_list.push_back(((pos.x, pos.y), 0.0));
            let idx = self.xy_idx(pos.x, pos.y);
            self.tiles[idx] = 0.0;
        }
        while let Some(((x, y), depth)) = open_list.pop_front() {
            let exits = map.get_available_exits(x, y);
            for (x, y, add_depth) in exits {
                let idx = self.xy_idx(x, y);
                let new_depth = depth + add_depth;
                let prev_depth = self.tiles[idx];
                if new_depth >= prev_depth { continue; }
                if new_depth >= self.max_depth { continue; }
                self.tiles[idx] = new_depth;
                open_list.push_back(((x, y), new_depth));
            }
        }
    }
fn build ( & mut self , map : & Map ) { let mapsize : usize = ( self . size_x * self . size_y ) as usize ; let mut open_list : VecDeque < ( ( usize , usize ) , f32 ) > = VecDeque :: with_capacity ( mapsize ) ; if let Some ( pos ) = map . starting_point { open_list . push_back ( ( ( pos . x , pos . y ) , 0.0 ) ) ; let idx = self . xy_idx ( pos . x , pos . y ) ; self . tiles [ idx ] = 0.0 ; } while let Some ( ( ( x , y ) , depth ) ) = open_list . pop_front ( ) { let exits = map . get_available_exits ( x , y ) ; for ( x , y , add_depth ) in exits { let idx = self . xy_idx ( x , y ) ; let new_depth = depth + add_depth ; let prev_depth = self . tiles [ idx ] ; if new_depth >= prev_depth { continue ; } if new_depth >= self . max_depth { continue ; } self . tiles [ idx ] = new_depth ; open_list . push_back ( ( ( x , y ) , new_depth ) ) ; } } }
Builds the Dijkstra map: iterate from each starting point, to each exit provided by BaseMap's
exits implementation.
Builds the Dijkstra map : iterate from each starting point to each exit provided by BaseMap ' s exits implementation .
&mut self
map
&Map
&mut self
map
&Map