protected AddInitialCell ( CPos location ) : void | ||
location | CPos | |
return | void |
public static IPathSearch FromPoints(World world, Locomotor locomotor, Actor self, IEnumerable <CPos> froms, CPos target, BlockedByActor check) { var graph = new PathGraph(LayerPoolForWorld(world), locomotor, self, world, check); var search = new PathSearch(graph); search.heuristic = search.DefaultEstimator(target); // The search will aim for the shortest path by default, a weight of 100%. // We can allow the search to find paths that aren't optimal by changing the weight. // We provide a weight that limits the worst case length of the path, // e.g. a weight of 110% will find a path no more than 10% longer than the shortest possible. // The benefit of allowing the search to return suboptimal paths is faster computation time. // The search can skip some areas of the search space, meaning it has less work to do. // We allow paths up to 25% longer than the shortest, optimal path, to improve pathfinding time. search.heuristicWeightPercentage = 125; search.isGoal = loc => { var locInfo = search.Graph[loc]; return(locInfo.EstimatedTotal - locInfo.CostSoFar == 0); }; foreach (var sl in froms) { if (world.Map.Contains(sl)) { search.AddInitialCell(sl); } } return(search); }
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; }
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; }
public static IPathSearch FromPoints(IWorld world, IMobileInfo mi, IActor 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); }
public static IPathSearch FromPoint(IWorld world, IMobileInfo mi, IActor 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); }
public static PathSearch ToTargetCellByPredicate( World world, Locomotor locomotor, Actor self, IEnumerable <CPos> froms, Func <CPos, bool> targetPredicate, BlockedByActor check, Func <CPos, int> customCost = null) { var graph = new PathGraph(LayerPoolForWorld(world), locomotor, self, world, check, customCost, null, false, DefaultLaneBias); var search = new PathSearch(graph, loc => 0, DefaultHeuristicWeightPercentage, targetPredicate); foreach (var sl in froms) { if (world.Map.Contains(sl)) { search.AddInitialCell(sl); } } return(search); }
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; }
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); }
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); }
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); }
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; }