Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.93 KB | None | 0 0
  1. while (maze[CurrentPosition.Row][CurrentPosition.Column] != '.' || MoveStack.Empty() == true)
  2.         {
  3.         //create west and north coordinates
  4.         Coordinate West, North, South, East;
  5.    
  6.         West.Row = CurrentPosition.Row;
  7.         West.Column = CurrentPosition.Column - 1;
  8.  
  9.         North.Row = CurrentPosition.Row - 1;
  10.         North.Column = CurrentPosition.Column;
  11.  
  12.         South.Row = CurrentPosition.Row + 1;
  13.         South.Column = CurrentPosition.Column;
  14.    
  15.         East.Row = CurrentPosition.Row;
  16.         East.Column = CurrentPosition.Column + 1;
  17.  
  18.         //Is west available? If so, push it on the move stack
  19.         if (MoveStack.AvailableMove(West, maze))
  20.         {
  21.             if (!MoveStack.Push(West))
  22.             {
  23.                 cout << "Memory error" << endl;
  24.                 exit(0);
  25.             }
  26.         }
  27.  
  28.         //Is north available? If so, push it on the move stack
  29.         if (MoveStack.AvailableMove(North,maze))
  30.         {
  31.             if (!MoveStack.Push(North))
  32.             {
  33.                 cout << "Memory error" << endl;
  34.                 exit(0);
  35.             }
  36.         }
  37.  
  38.         if (MoveStack.AvailableMove(South,maze))
  39.         {
  40.             if (!MoveStack.Push(South))
  41.             {
  42.                 cout << "Memory error" << endl;
  43.                 exit(0);
  44.             }
  45.         }
  46.  
  47.         if (MoveStack.AvailableMove(East,maze))
  48.         {
  49.             if (!MoveStack.Push(East))
  50.             {
  51.                 cout << "Memory error" << endl;
  52.                 exit(0);
  53.             }
  54.         }
  55.  
  56.         maze[CurrentPosition.Row][CurrentPosition.Column] = '.';
  57.  
  58.         if (!MoveStack.Pop(CurrentPosition))
  59.         {
  60.             cout << "Stack Empty" << endl;
  61.  
  62.             fout << "MAZE NUMBER:" << MazeCount << endl << endl;
  63.             for (rIndex = 0; rIndex < row; rIndex++)
  64.             {
  65.                 for (cIndex = 0; cIndex < col; cIndex++)
  66.                 {
  67.                     fout << maze[rIndex][cIndex];
  68.                 }
  69.                 fout << endl;
  70.             }
  71.  
  72.             fout << "There IS NOT a way out!!" << endl;
  73.         }
  74.  
  75.  
  76.         if (maze[CurrentPosition.Row][CurrentPosition.Column] == 'E')
  77.             {
  78.                 for (rIndex = 0; rIndex < row; rIndex++)
  79.                 {
  80.                     for (cIndex = 0; cIndex < col; cIndex++)
  81.                         {
  82.                             fout << maze[rIndex][cIndex];
  83.                         }
  84.                         fout << endl;
  85.                 }
  86.                 fout << "There IS a way out!" << endl;
  87.  
  88.             }
  89.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement