コード例 #1
0
    public static MazeNode FindPathEnd(MazeNode root)
    {
        MazeNode previous       = new MazeNode(-1, -1);
        MazeNode current        = root;
        bool     currentChanged = false;
        int      counter        = 0;

        while (!previous.Equals(current) && counter < 1000)
        {
            foreach (MazeNode n in current.GetAdjacentNodes())
            {
                if (n.OnExitPath && !n.Equals(previous))
                {
                    previous       = current;
                    current        = n;
                    currentChanged = true;
                    break;
                }
            }

            if (!currentChanged)
            {
                previous = current;
            }
            currentChanged = false;
            counter++;
        }
        return(current);
    }
コード例 #2
0
 /// <summary>
 /// Checks if node is target node.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public bool IsTarget(MazeNode node)
 {
     return(node.Equals(_end));
 }