Question: Maze Runner C Code Project which i'm confused on how to complete, any help would be much appreciated. I was given 3 files First File
Maze Runner C Code Project which i'm confused on how to complete, any help would be much appreciated.


I was given 3 files
First File - maze_runner.c
#include#include #include "mazelib.h" #include "runner.h" void usage(void); int main(int argc, char* argv[]) { if (argc Second File - mazelib.h
#ifndef _maze_h #define _maze_h #include//---- Directional Constants ------------------------------------------------// typedef enum { NORTH = 0, EAST, SOUTH, WEST } direction; //---- Function Prototypes // Initializes the maze according to the width and height passed in. The width and height should both be // greater than 8. The width should also be less than 80 and the height should be less than 26. // // The start of the maze is always in the upper left of the maze at coordinates (1, 1) and is marked with // an 'S'. Likewise the exit or end of the maze is always in the lower right corner and marked with an // 'E'. The coordinates of the exit vary since mazes of different sizes may be used bool maze_init(int width, int height); // Gets the width of the maze. This and the following function both return -1 in case of an error. This // could be caused by calling either of these functions before calling maze_init(). int maze_get_width(void); // Gets the height of the maze. This and the following function both return -1 in case of an error. This // could be caused by calling either of these functions before calling maze_init(). int maze_get_height(void); // returns true if the coordinate supplied is within the bounds of the maze and false otherwise. bool maze_is_coord_in_bounds(int x, int y); // Returns the character in the maze at a given coordinate. A return value of '#' represents a wall, 'S' // represents the starting place of the robot, 'E' represents the exit and ' ' represents an open space. char maze_get_char(int x, int y); // This function can be used to set a character in the maze to something new. It will not set a square // that's filled with a wall ('#'), the start of the maze marker ('S'), or the end of the maze marker // ('E'). bool maze_set_char(int x, int y, char new_val); // This function prints the maze as it currently is void maze_print(void); #endif Third File - mazelib.c
#include#include #include #include #include "mazelib.h" static void shuffle_dirs(direction*); static int xy_to_index(int, int); static void reset(void); static bool are_valid_maze_dimensions(int, int); static void set_offsets_for_dir(int*, int*, direction); static void maze_visit(int, int); static int width; static int height; static char *maze; static bool initializing = false; // maze_init allocates the memory for the maze array based on width and height bool maze_init(int w, int h) { if(!are_valid_maze_dimensions(w, h)) { return false; } width = w; height = h; srand(time(NULL)); maze = malloc(sizeof(*maze) * width * height); reset(); initializing = true; maze_visit(1, 1); maze_set_char(1, 1, 'S'); maze_set_char(width-2, height-2, 'E'); initializing = false; return true; } int maze_get_width(void) { return width; } int maze_get_height(void) { return height; } // returns "true" if x and y are both in-bounds defined by: // 0 8 && h > 8 && w When an 'o' is crossed, an ' should result. Finally, when an 'O' is crossed, an 'a' should be left in its place Things to Remember and Helpful Hints: Make sure you read all of the comments in the "mazelib.h" header file! These comments will tell you all you need to know about interacting with the maze features of C available to you. A good way to start this project would simply be to create your h and c files and fill in a skeleton for the necessary functions. They can just do nothing and return, but this will let you test your Makefile by compiling the project. After that, you can run the program to make sure everything is working and then begin to implement your solver logic. Grading Specification For your submission to receive a grade of pass', it must fulfill the following criteria: It must be submitted correctly I must be able to compile your program simply by invoking "make" in a directory containing your code and Makefile. The program must compile with no warnings or errors The program should run wit h no errors and output a legally solved version of the generated maze. When an 'o' is crossed, an ' should result. Finally, when an 'O' is crossed, an 'a' should be left in its place Things to Remember and Helpful Hints: Make sure you read all of the comments in the "mazelib.h" header file! These comments will tell you all you need to know about interacting with the maze features of C available to you. A good way to start this project would simply be to create your h and c files and fill in a skeleton for the necessary functions. They can just do nothing and return, but this will let you test your Makefile by compiling the project. After that, you can run the program to make sure everything is working and then begin to implement your solver logic. Grading Specification For your submission to receive a grade of pass', it must fulfill the following criteria: It must be submitted correctly I must be able to compile your program simply by invoking "make" in a directory containing your code and Makefile. The program must compile with no warnings or errors The program should run wit h no errors and output a legally solved version of the generated maze
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
