extern int getTotalKeys();.

Added on - 20 Sep 2019

  • 2

    Pages

  • 405

    Words

  • 89

    Views

  • 0

    Downloads

Trusted by +2 million users,
1000+ happy students everyday
Showing pages 1 to 1 of 2 pages
extern int getTotalKeys();extern int getCurrentKeys();extern int getNumSteps(); // returns the number of steps which you have madeso far. Might be useful for debugging purposes.extern void getCurrentPosition(int * arr); // this puts the player's row intoarr[0], and the player's column into arr[1].extern void readMaze(); // points will be taken off if you use this.extern void printMaze(); // prints the current maze. Might be useful fordebugging.extern int isComplete(); //returns 1 if the maze is complete, and 0 otherwise.Useful for loop conditionsextern int move(int newRow, int newCol); // if possible, it moves the playerto the position specified. Returns 1 if successful move, 0 otherwise. If notpossible, it prints a handy error message explaining what happened. You aredefinitely allowed to comment out the print statements if you get tired ofseeing the error messages.extern int look(int newRow, int newCol); // if possible, it tells you what'sin the square you are looking at. It also returns the integer value of what isin the square (see maze file explanation), or -1 if the look failed. If notpossible, it prints a handy error message explaining what happened. You aredefinitely allowed to comment out the print statements if you get tired ofseeing the error messages.void solveMaze();int moveRight();int moveLeft();void solveMaze(){printMaze();while(!isComplete()){while(moveLeft()){printMaze();}while(moveRight()){printMaze();}}}int moveRight(){int currentPos[2];getCurrentPosition(currentPos);return move(currentPos[0], currentPos[1]+1);}int moveLeft(){int currentPos[2];getCurrentPosition(currentPos);return move(currentPos[0], currentPos[1]-1);}
desklib-logo
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document