Ejemplo n.º 1
0
 public void GenerateWalls(IIndexedPathfindingMap map, int count)
 {
     for (var i = 0; i < count; i++)
     {
         GenerateWall(map);
     }
 }
Ejemplo n.º 2
0
        private void GenerateWall(IIndexedPathfindingMap map)
        {
            var start = map.RandomOpenCell();
            var end = map.RandomOpenCell();

            //don't allow walls to start and end in the same place.
            while (start == end) { end = map.RandomOpenCell(); }

            var cellsInLine = map.CellsInLine(start, end);

            foreach (var cell in cellsInLine)
            {
                map.Set(cell, CellState.Wall);
                map.Set(map.GetNeighbors(cell), CellState.Wall);
            }
        }
Ejemplo n.º 3
0
        public void CreateSolver(AlgorithmType algoType, IIndexedPathfindingMap map, double heuristic, 
            out IPathFinder<Vector2i> pathFinder, out IPathFindingListener<Vector2i> listener)
        {
            switch (algoType)
            {
                case AlgorithmType.AStar:
                    listener = new AStarListener();
                    pathFinder = new AStar<Vector2i>(map.GetNeighbors, map.DistanceEstimate, heuristic)
                    {
                        Listener = (IAStarListener<Vector2i>)listener
                    };
                    return;
                case AlgorithmType.Dijkstra:
                    listener = new DijkstraListener();
                    pathFinder = new Dijkstra<Vector2i>(map.GetNeighbors, map.DistanceEstimate)
                    {
                        Listener = listener
                    };
                    return;
            }

            throw new Exception($"Unrecognized algorithm type: {algoType}");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Rebuilds the graph based on the current GridType
        /// </summary>
        private void RebuildGraph()
        {
            m_Grid = IndexedPathfindingMapFactory.BuildMap(m_GridType, m_NodeSize, m_Window.Size, StateToColorMap);

            SimulationAction = SimulationAction.None;
            ResetGraph();
        }