Inheritance: BasePathSearch
Example #1
0
        public static IPathSearch FromPoints(World world, MobileInfo mi, Actor self, IEnumerable<CPos> froms, CPos target, bool checkForBlocked)
        {
            var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            foreach (var sl in froms.Where(sl => world.Map.Contains(sl)))
                search.AddInitialCell(sl);

            return search;
        }
Example #2
0
        public static IPathSearch FromPoint(World world, MobileInfo mi, Actor self, CPos from, CPos target, bool checkForBlocked)
        {
            var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            if (world.Map.Contains(from))
                search.AddInitialCell(from);

            return search;
        }
Example #3
0
        public static IPathSearch FromPoints(World world, MobileInfo mi, Actor self, IEnumerable<CPos> froms, CPos target, bool checkForBlocked)
        {
            var graph = new PathGraph(LayerPoolForWorld(world), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            search.isGoal = loc =>
            {
                var locInfo = search.Graph[loc];
                return locInfo.EstimatedTotal - locInfo.CostSoFar == 0;
            };

            foreach (var sl in froms.Where(sl => world.Map.Contains(sl)))
                search.AddInitialCell(sl);

            return search;
        }
Example #4
0
        public static IPathSearch FromPoint(World world, MobileInfo mi, Actor self, CPos from, CPos target, bool checkForBlocked)
        {
            var graph = new PathGraph(LayerPoolForWorld(world), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            search.isGoal = loc =>
            {
                var locInfo = search.Graph[loc];
                return locInfo.EstimatedTotal - locInfo.CostSoFar == 0;
            };

            if (world.Map.Contains(from))
                search.AddInitialCell(from);

            return search;
        }
Example #5
0
        public static IPathSearch FromPoints(World world, MobileInfo mi, Actor self, IEnumerable <CPos> froms, CPos target, bool checkForBlocked)
        {
            var graph  = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            search.isGoal = loc =>
            {
                var locInfo = search.Graph[loc];
                return(locInfo.EstimatedTotal - locInfo.CostSoFar == 0);
            };

            foreach (var sl in froms.Where(sl => world.Map.Contains(sl)))
            {
                search.AddInitialCell(sl);
            }

            return(search);
        }
Example #6
0
        public static IPathSearch FromPoint(World world, MobileInfo mi, Actor self, CPos from, CPos target, bool checkForBlocked)
        {
            var graph  = new PathGraph(LayerPoolForWorld(world), mi, self, world, checkForBlocked);
            var search = new PathSearch(graph)
            {
                heuristic = DefaultEstimator(target)
            };

            search.isGoal = loc =>
            {
                var locInfo = search.Graph[loc];
                return(locInfo.EstimatedTotal - locInfo.CostSoFar == 0);
            };

            if (world.Map.Contains(from))
            {
                search.AddInitialCell(from);
            }

            return(search);
        }
Example #7
0
        public static PathSearch ToTargetCell(
            World world, Locomotor locomotor, Actor self, IEnumerable <CPos> froms, CPos target, BlockedByActor check,
            Func <CPos, int> customCost = null,
            Actor ignoreActor           = null,
            bool laneBias                 = true,
            bool inReverse                = false,
            Func <CPos, int> heuristic    = null,
            int heuristicWeightPercentage = DefaultHeuristicWeightPercentage)
        {
            var graph = new MapPathGraph(LayerPoolForWorld(world), locomotor, self, world, check, customCost, ignoreActor, laneBias, inReverse);

            heuristic = heuristic ?? DefaultCostEstimator(locomotor, target);
            var search = new PathSearch(graph, heuristic, heuristicWeightPercentage, loc => loc == target);

            foreach (var sl in froms)
            {
                if (world.Map.Contains(sl))
                {
                    search.AddInitialCell(sl);
                }
            }

            return(search);
        }
Example #8
0
 public static IPathSearch Search(World world, MobileInfo mi, Actor self, bool checkForBlocked, Func<CPos, bool> goalCondition)
 {
     var graph = new PathGraph(LayerPoolForWorld(world), mi, self, world, checkForBlocked);
     var search = new PathSearch(graph);
     search.isGoal = goalCondition;
     search.heuristic = loc => 0;
     return search;
 }
Example #9
0
 public static IPathSearch Search(World world, MobileInfo mi, Actor self, bool checkForBlocked, Func<CPos, bool> goalCondition)
 {
     var graph = new PathGraph(CellInfoLayerManager.Instance.NewLayer(world.Map), mi, self, world, checkForBlocked);
     var search = new PathSearch(graph);
     search.isGoal = goalCondition;
     search.heuristic = loc => 0;
     return search;
 }