#ifndef _MAZE_H_ #define _MAZE_H_ // direction definition for Move()/Look() operations typedef enum {north, south, east, west} direction; // possible return values from Move(), Look(), Jump() operations typedef enum {POS_UNVISITED = -1, POS_BLOCKED = 0, POS_CLEAR = 1, POS_GOAL = 2} status; class Maze { private: char* maze; int mazerows, mazecols; int currow, curcol; int goalrow, goalcol; int numlooks, nummoves, numjumps; private: void NewPos(direction dir, int& newrow, int& newcol); public: /***********************************/ /* Constructors, Destructors, etc. */ /***********************************/ Maze(char* filename); // The only constructor -- takes a filename, reads the enclosed maze and // initializes all the class variables Maze(const Maze& rhs); const Maze& operator=(const Maze& rhs); // Overriding the default copy constructor and = operator to prevent // illegal copying of the maze (which would throw off the statistics // being gathered and the state indicating where you've been. Pass // the maze by reference to avoid using these. ~Maze(); // Destructor prints out statistics indicating the number of looks, // moves, and jumps /***********************************/ /* Query operations */ /***********************************/ void Size(int& numrows,int& numcols); // Sets the parameters to indicate the maze size void Position(int& row, int& col); // Sets the parameters to indicate the current position void Goal(int& row, int& col); // Sets the parameters to indicate the goal's position /***********************************/ /* Action operations */ /***********************************/ status Look(direction dir); // Look in the specified direction. // Returns: // POS_BLOCKED if it contains a wall // POS_CLEAR if it's clear // POS_GOAL if it's the goal. // This call increments the number of looks that you've used. status Move(direction dir); // Move in the specified direction. // Returns: // POS_BLOCKED if it contains a wall // POS_CLEAR if it's clear // POS_GOAL if it's the goal. // This call increments the number of moves if it's successful, and // increments the number of looks if it's not. status Jump(int row, int col); // Jump to the specified coordinate (which you've visited before). // Returns: // POS_UNVISITED if you haven't visited that coordinate before // POS_BLOCKED if it's blocked // POS_CLEAR if it's clear // POS_GOAL if it contains the goal. // This call increments the number of jumps whether or not it's // successful. void Print(int pretty = 1); // Print out the maze. If pretty is set to 0 the internal // representation of the maze is printed out (for debugging purposes // only). Otherwise, a more readable format is used }; #endif