Beispiel #1
0
 private void UpdateVertex(LayerTile u)
 {
     if (!gScore.ContainsKey(u))
     {
         gScore[u] = float.PositiveInfinity;
     }
     if (u != end)
     {
         float minVal = float.PositiveInfinity;
         foreach (Point neighborPoint in fog.Adjacents(u, adjPoints))
         {
             LayerTile s = map.GetTileByMapCoordinates(neighborPoint.X, neighborPoint.Y);
             if (!gScore.ContainsKey(s))
             {
                 gScore[s] = float.PositiveInfinity;
             }
             float currVal = (DistBetween(u, s)) + gScore[s];
             if (minVal > currVal)
             {
                 minVal = currVal;
             }
         }
         rhs[u] = minVal;
     }
     if (openSet.ContainsKey(u))
     {
         openSet.Remove(u);
     }
     if (gScore[u] != rhs[u])
     {
         fScore[u] = CalculateKey(u);
         openSet.Add(u, fScore[u]);
     }
 }
Beispiel #2
0
        /**
         * <summary>
         * Finds adjacent and possibly free tiles to the one given
         * </summary>
         */
        private List <LayerTile> IsAdjacentTileFree(LayerTile tile, DStarLite dstar)
        {
            List <LayerTile> res = new List <LayerTile>();

            if (tile != null)
            {
                foreach (Point neighborPoint in fog.Adjacents(tile, dstar.adjPoints))
                {
                    LayerTile u = map.GetTileByMapCoordinates(neighborPoint.X, neighborPoint.Y);
                    if (dstar.CalculateDistance(u) != float.PositiveInfinity)
                    {
                        res.Add(u);
                    }
                }
            }
            return(res);
        }