private List <PathNode> GetNeighbours(PathNode pathNode, Point goal, bool[,] field) { var result = new List <PathNode>(); var neighbourPoints = _helper.GetNeighbourPoints(pathNode.Position); foreach (var point in neighbourPoints) { if (!_helper.IsPointAvailableToMove(field, point)) { continue; } var neighbourNode = new PathNode { Position = point, CameFrom = pathNode, PathLengthFromStart = pathNode.PathLengthFromStart + DistanceBetweenNeighbours, HeuristicEstimatePathLength = GetHeuristicPathLength(point, goal) }; result.Add(neighbourNode); } return(result); }
public LinkedList <Point> FindPath(bool[,] field, Point start, Point goal) { var neighbourPoints = _helper.GetNeighbourPoints(start); var availablePoints = neighbourPoints.Where(point => _helper.IsPointAvailableToMove(field, point)).ToList(); var rand = new Random(); var availablePoint = availablePoints[rand.Next(0, availablePoints.Count)]; var result = new LinkedList <Point>(); result.AddFirst(availablePoint); return(result); }