Ejemplo n.º 1
0
        private void MoveCurrent(int ThisPop, ref MazeCell Current, ref MyStack stack)
        {
            // SET CURRENT - setMove in opposite direction because we are revearsing
            // 1 = W, 2 = S, 3 = E, 4 = N
            switch (ThisPop)
            {
            case -1:
                // TODO: Fix recursion loop if stack.Top() fails to be a listed case
                MoveCurrent(stack.Top(), ref Current, ref stack);
                break;

            case 1:
                Current.MoveEast();
                break;

            case 2:
                Current.MoveNorth();
                break;

            case 3:
                Current.MoveWest();
                break;

            case 4:
                Current.MoveSouth();
                break;

            default:
                // ERROR - Unidentified Direction or Choice
                break;
            }
        }
Ejemplo n.º 2
0
 private void TakeNextStep(ref MazeCell Current, int[] next, ref MyStack stack)
 {
     // Directions are based off of how NEXT is set during CHECK-AROUND method
     if (Current.Column > next[0] && Current.Row == next[1])
     {
         // Go West = 1
         stack.Push(1);
         ChangeTile(Current);
         Current.MoveWest();
     }
     else if (Current.Column == next[0] && Current.Row < next[1])
     {
         // Go South = 2
         stack.Push(2);
         ChangeTile(Current);
         Current.MoveSouth();
     }
     else if (Current.Column < next[0] && Current.Row == next[1])
     {
         // Go East = 3
         stack.Push(3);
         ChangeTile(Current);
         Current.MoveEast();
     }
     else if (Current.Column == next[0] && Current.Row > next[1])
     {
         // Go North = 4
         stack.Push(4);
         ChangeTile(Current);
         Current.MoveNorth();
     }
     else
     {
         if (next[0] == -1 || next[1] == -1)
         {
             // NO PATH
             RewindPath(ref stack, ref Current);
         }
         else
         {
             // Error in Path
         }
     }
 }