Beispiel #1
0
        static Point FindNext(pathdirection dir, Point node)
        {
            Point nextLoc = null;

            switch (dir)
            {
            case pathdirection.north:
                nextLoc = node.x - 1 >= 0 ? new Point(node.x - 1, node.y) : null;
                break;

            case pathdirection.south:
                nextLoc = node.x + 1 < points.GetLength(0) ? new Point(node.x + 1, node.y) : null;
                break;

            case pathdirection.east:
                nextLoc = node.y + 1 < points.GetLength(0) ? new Point(node.x, node.y + 1) : null;
                break;

            case pathdirection.west:
                nextLoc = node.y - 1 >= 0 ? new Point(node.x, node.y - 1) : null;
                break;

            default:
                break;
            }
            return(nextLoc);
        }
Beispiel #2
0
        static int AddNextNode(pathdirection dir, Node node)
        {
            Point nextNode = FindNext(dir, node.Locate);

            if (nextNode != null && points[nextNode.x][nextNode.y] < node.NodeValue)
            {
                allNodes.Add(new Node(runningValueID++, nextNode, points[nextNode.x][nextNode.y], node.Id, runningLevel + 1));
                return(1);
            }
            return(0);
        }