private static void TryAddPosition(Map map, Direction direction, InternalPoint position, int xOffset, int yOffset) { var availableDirections = map.AvailableDirectionsByCoordinates[position.X, position.Y]; var point = new InternalPoint(position.X + xOffset, position.Y + yOffset, direction); if ( (availableDirections & direction)!= 0 && !handled.Contains(point)) { AddPoint(point); parents.SafeAdd(point, position); } }
private static void TryAddPosition(Map map, Direction direction, InternalPoint position, int xOffset, int yOffset) { var availableDirections = map.AvailableDirectionsByCoordinates[position.X, position.Y]; var point = new InternalPoint(position.X + xOffset, position.Y + yOffset, direction); if ((availableDirections & direction) != 0 && !handled.Contains(point)) { AddPoint(point); parents.SafeAdd(point, position); } }
public static Direction[] FindPath(Map map, Point from, Point to) { var lastDirection = Bfs(map, from, to); var directions = new List<Direction>(); var currentPoint = new InternalPoint(to.X, to.Y, lastDirection); while (parents.ContainsKey(currentPoint)) { directions.Add(currentPoint.Direction); currentPoint = parents[currentPoint]; } directions.Reverse(); return directions.ToArray(); }
public static Direction[] FindPath(Map map, Point from, Point to) { var lastDirection = Bfs(map, from, to); var directions = new List <Direction>(); var currentPoint = new InternalPoint(to.X, to.Y, lastDirection); while (parents.ContainsKey(currentPoint)) { directions.Add(currentPoint.Direction); currentPoint = parents[currentPoint]; } directions.Reverse(); return(directions.ToArray()); }
protected bool Equals(InternalPoint other) { return X == other.X && Y == other.Y; }
private static void AddPoint(InternalPoint point) { queue.Enqueue(point); handled.Add(point); }
protected bool Equals(InternalPoint other) { return(X == other.X && Y == other.Y); }