private static int MakeLazyKey(AStarFindHeuristic heuristic, int[][] map, int[] limits, int sx, int sy, int ex, int ey, bool flag) { int hashCode = 1; int w = map.Length; int h = map[0].Length; for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { hashCode = LSystem.Unite(hashCode, map[i][j]); } } if (limits != null) { for (int i = 0; i < limits.Length; i++) { hashCode = LSystem.Unite(hashCode, limits[i]); } } hashCode = LSystem.Unite(hashCode, heuristic.GetType()); hashCode = LSystem.Unite(hashCode, sx); hashCode = LSystem.Unite(hashCode, sy); hashCode = LSystem.Unite(hashCode, ex); hashCode = LSystem.Unite(hashCode, ey); hashCode = LSystem.Unite(hashCode, flag); return(hashCode); }
public List<Vector2f> Search(AStarFindHeuristic heuristic, int startX, int startY, int endX, int endY, bool flying, bool flag) { return new AStarFinder(heuristic, field, startX, startY, endX, endY, flying, flag).FindPath(); }
private static int MakeLazyKey(AStarFindHeuristic heuristic, int[][] map, int[] limits, int sx, int sy, int ex, int ey, bool flag) { int hashCode = 1; int w = map.Length; int h = map[0].Length; for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { hashCode = LSystem.Unite(hashCode, map[i][j]); } } if (limits != null) { for (int i = 0; i < limits.Length; i++) { hashCode = LSystem.Unite(hashCode, limits[i]); } } hashCode = LSystem.Unite(hashCode, heuristic.GetType()); hashCode = LSystem.Unite(hashCode, sx); hashCode = LSystem.Unite(hashCode, sy); hashCode = LSystem.Unite(hashCode, ex); hashCode = LSystem.Unite(hashCode, ey); hashCode = LSystem.Unite(hashCode, flag); return hashCode; }
public List <Vector2f> Search(AStarFindHeuristic heuristic, int startX, int startY, int endX, int endY, bool flying, bool flag) { return(new AStarFinder(heuristic, field, startX, startY, endX, endY, flying, flag).FindPath()); }
public void Update(AStarFinder Find) { this.field = Find.field; this.startX = Find.startX; this.startY = Find.startY; this.endX = Find.endX; this.endY = Find.endY; this.flying = Find.flying; this.flag = Find.flag; this.findHeuristic = Find.findHeuristic; }
public void Search(AStarFindHeuristic heuristic, int startx, int starty, int endx, int endy, bool flying, bool flag, AStarFinderListener callback) { AStarFinder pathfinderTask = new AStarFinder(heuristic, field, startx, starty, endx, endy, flying, flag, callback); AStarFinder existing = pathQueue.Contains(pathfinderTask); if (existing != null) { existing.Update(pathfinderTask); } else { pathQueue.Add(pathfinderTask); } pathfinderThread.Interrupt(); }
public AStarFinder(AStarFindHeuristic heuristic, Field2D field_0, int startX_1, int startY_2, int endX_3, int endY_4, bool flying_5, bool flag_6, AStarFinderListener callback) { this.field = field_0; this.startX = startX_1; this.startY = startY_2; this.endX = endX_3; this.endY = endY_4; this.flying = flying_5; this.flag = flag_6; this.pathFoundListener = callback; this.findHeuristic = heuristic; }
public static List <Vector2f> Find(AStarFindHeuristic heuristic, int[][] maps, int[] limits, int x1, int y1, int x2, int y2, bool flag) { heuristic = ((heuristic == null) ? ASTAR_MANHATTAN : heuristic); lock (finderLazy) { if (finderLazy.Count >= LSystem.DEFAULT_MAX_CACHE_SIZE * 10) { finderLazy.Clear(); } int key = MakeLazyKey(heuristic, maps, limits, x1, y1, x2, y2, flag); List <Vector2f> result = (List <Vector2f>)CollectionUtils.Get(finderLazy, key); if (result == null) { AStarFinder astar = new AStarFinder(heuristic); Field2D fieldMap = new Field2D(maps); if (limits != null) { fieldMap.SetLimit(limits); } Vector2f start = new Vector2f(x1, y1); Vector2f over = new Vector2f(x2, y2); result = astar.Calc(fieldMap, start, over, flag); CollectionUtils.Put(finderLazy, key, result); astar.Dispose(); } if (result != null) { List <Vector2f> newResult = new List <Vector2f>(); CollectionUtils.AddAll(newResult, result); result = newResult; } return(result); } }
public static List<Vector2f> Find(AStarFindHeuristic heuristic, int[][] maps, int[] limits, int x1, int y1, int x2, int y2, bool flag) { heuristic = ((heuristic == null) ? ASTAR_MANHATTAN : heuristic); lock (finderLazy) { if (finderLazy.Count >= LSystem.DEFAULT_MAX_CACHE_SIZE * 10) { finderLazy.Clear(); } int key = MakeLazyKey(heuristic, maps, limits, x1, y1, x2, y2, flag); List<Vector2f> result = (List<Vector2f>)CollectionUtils.Get(finderLazy, key); if (result == null) { AStarFinder astar = new AStarFinder(heuristic); Field2D fieldMap = new Field2D(maps); if (limits != null) { fieldMap.SetLimit(limits); } Vector2f start = new Vector2f(x1, y1); Vector2f over = new Vector2f(x2, y2); result = astar.Calc(fieldMap, start, over, flag); CollectionUtils.Put(finderLazy, key, result); astar.Dispose(); } if (result != null) { List<Vector2f> newResult = new List<Vector2f>(); CollectionUtils.AddAll(newResult, result); result = newResult; } return result; } }
public AStarFinder(AStarFindHeuristic heuristic, bool flying_0) { this.flying = flying_0; this.findHeuristic = heuristic; }
public AStarFinder(AStarFindHeuristic heuristic) : this(heuristic, false) { }
public static List <Vector2f> Find(AStarFindHeuristic heuristic, int[][] maps, Vector2f start, Vector2f goal, bool flag) { return(Find(heuristic, maps, start.X(), start.Y(), goal.X(), goal.Y(), flag)); }
public static List <Vector2f> Find(AStarFindHeuristic heuristic, Field2D maps, Vector2f start, Vector2f goal, bool flag) { return(Find(heuristic, maps.GetMap(), maps.GetLimit(), start.X(), start.Y(), goal.X(), goal.Y(), flag)); }
public static List <Vector2f> Find(AStarFindHeuristic heuristic, Field2D maps, int x1, int y1, int x2, int y2, bool flag) { return(Find(heuristic, maps.GetMap(), maps.GetLimit(), x1, y1, x2, y2, flag)); }
public static List <Vector2f> Find(AStarFindHeuristic heuristic, int[][] maps, int x1, int y1, int x2, int y2, bool flag) { return(Find(heuristic, maps, x1, y1, x2, y2, flag)); }
public static List<Vector2f> Find(AStarFindHeuristic heuristic, int[][] maps, Vector2f start, Vector2f goal, bool flag) { return Find(heuristic, maps, start.X(), start.Y(), goal.X(), goal.Y(), flag); }
public static List<Vector2f> Find(AStarFindHeuristic heuristic, int[][] maps, int x1, int y1, int x2, int y2, bool flag) { return Find(heuristic, maps, x1, y1, x2, y2, flag); }
public void Search(AStarFindHeuristic heuristic, int startx, int starty, int endx, int endy, bool flying, AStarFinderListener callback) { Search(heuristic, startx, starty, endx, endy, flying, false, callback); }
public static List<Vector2f> Find(AStarFindHeuristic heuristic, Field2D maps, int x1, int y1, int x2, int y2, bool flag) { return Find(heuristic, maps.GetMap(), maps.GetLimit(), x1, y1, x2, y2, flag); }
public AStarFinder(AStarFindHeuristic heuristic, Field2D field_0, int startX_1, int startY_2, int endX_3, int endY_4, bool flying_5, bool flag_6) : this(heuristic, field_0, startX_1, startY_2, endX_3, endY_4, flying_5, flag_6, null) { }
public static List<Vector2f> Find(AStarFindHeuristic heuristic, Field2D maps, Vector2f start, Vector2f goal, bool flag) { return Find(heuristic, maps.GetMap(), maps.GetLimit(), start.X(), start.Y(), goal.X(), goal.Y(), flag); }
public void SetHeuristic(AStarFindHeuristic h) { this.heuristic = h; }
public void setHeuristic(AStarFindHeuristic heuristic) { this.heuristic = heuristic; }