Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 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);
        }