Beispiel #1
0
        public List <BreadthFirstSearchNode> GetUnivisitedAdjacentNodes(BreadthFirstSearchNode parent)
        {
            var nodes = new List <BreadthFirstSearchNode>();

            //above
            if (IsValidAdjacent(parent.X, parent.Y - 1))
            {
                var node = new BreadthFirstSearchNode(parent.X, parent.Y - 1);
                node.Parent = parent;
                nodes.Add(node);
            }

            //below
            if (IsValidAdjacent(parent.X, parent.Y + 1))
            {
                var node = new BreadthFirstSearchNode(parent.X, parent.Y + 1);
                node.Parent = parent;
                nodes.Add(node);
            }

            //left
            if (IsValidAdjacent(parent.X - 1, parent.Y))
            {
                var node = new BreadthFirstSearchNode(parent.X - 1, parent.Y);
                node.Parent = parent;
                nodes.Add(node);
            }

            //right
            if (IsValidAdjacent(parent.X + 1, parent.Y))
            {
                var node = new BreadthFirstSearchNode(parent.X + 1, parent.Y);
                node.Parent = parent;
                nodes.Add(node);
            }

            return(nodes);
        }
Beispiel #2
0
 public BreadthFirstSearchAlgorithm(int startX, int startY, int goalX, int goalY, string rawData)
 {
     P   = new BreadthFirstSearchNode(startX, startY);
     G   = new BreadthFirstSearchNode(goalX, goalY);
     map = new Map(rawData);
 }
Beispiel #3
0
        public bool IsNodeUnivisited(BreadthFirstSearchNode node)
        {
            var found = visited.FirstOrDefault(x => x.Equals(node));

            return(found == null);
        }