extern int getTotalKeys();.

Added on - Sep 2019

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 are reading a preview
Upload your documents to download or

Become a Desklib member to get access