Exemple #1
0
    private void Generate()
    {
        HierarchicalMapFactory factory         = new HierarchicalMapFactory();
        HierarchicalMap        hierarchicalMap = factory.CreateHierarchicalMap(m_concreteMap, m_clusterSize, m_maxLevel);
        List <PathNode>        path            = HierarchicalSearch.Search(factory, hierarchicalMap, m_maxLevel, m_startNode.Pos, m_goalNode.Pos);

        for (int i = 0; i < path.Count; i++)
        {
            var node = m_concreteMap.Get(path[i].Pos);
            node.SetSearchType(SearchType.Path);
        }
    }
Exemple #2
0
        private static List <IPathNode> HierarchicalSearch(HierarchicalMap hierarchicalMap, int maxLevel, ConcreteMap concreteMap, Position startPosition, Position endPosition)
        {
            var factory            = new HierarchicalMapFactory();
            var startAbsNode       = factory.InsertAbstractNode(hierarchicalMap, startPosition);
            var targetAbsNode      = factory.InsertAbstractNode(hierarchicalMap, endPosition);
            var maxPathsToRefine   = int.MaxValue;
            var hierarchicalSearch = new HierarchicalSearch();
            var abstractPath       = hierarchicalSearch.DoHierarchicalSearch(hierarchicalMap, startAbsNode, targetAbsNode, maxLevel, maxPathsToRefine);
            var path = hierarchicalSearch.AbstractPathToLowLevelPath(hierarchicalMap, abstractPath, hierarchicalMap.Width, maxPathsToRefine);

            var smoother = new SmoothWizard(concreteMap, path);

            path = smoother.SmoothPath();

            factory.RemoveAbstractNode(hierarchicalMap, targetAbsNode);
            factory.RemoveAbstractNode(hierarchicalMap, startAbsNode);

            return(path);
        }