Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here are the files I was given: mazelib.c : // PAY NO MIND TO ANYTHING FROM HERE #include #include #include #include #include mazelib.h static int

image text in transcribed

Here are the files I was given:

mazelib.c :

// PAY NO MIND TO ANYTHING FROM HERE #include  #include  #include  #include  #include "mazelib.h" static int xy_to_index(int, int); static int width; static int height; static char *maze; static bool initializing = false; // TO HERE //////////////////////////////////////////////////////////////////////////////// // BEGIN: THINGS YOU SHOULD LOOK AT // //////////////////////////////////////////////////////////////////////////////// /* maze_get_char returns the character in maze at the passed index */ char maze_get_char(int x, int y) { return maze[xy_to_index(x, y)]; } /* maze_set_char sets the character in maze at the passed index to the passed character. */ bool maze_set_char(int x, int y, char replacement) { char c = maze_get_char(x, y); if((c == '#' || c == 'S' || c == 'E') && !initializing) { return false; } maze[xy_to_index(x, y)] = replacement; return true; } // returns "true" if x and y are both in-bounds defined by: // 0  8 && h > 8 && w  

mazelib.h :

#ifndef _maze_h #define _maze_h #include  //---- Directional Constants ------------------------------------------------// // You can use this to track the direction your solver is facing enum direction { NORTH, EAST, SOUTH, WEST }; //---- 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. // IMPORTANT: The start of the maze is always in the upper left of the maze at (1, 1) bool maze_init(int width, int height); // 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 to something new though. 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

maze_runner.c :

#include  #include  #include  #include "mazelib.h" #include "runner.h" void usage(void); int main(int argc, char* argv[]) { if (argc   Overview In this project you will implement the logic of a maze solver in C. In the course of this project, you will get more practice with all of the fundamental programmatic structures of C as well as experience using external library code. Finally, you will need to create your first '.h' file to provide an interface to your code. Submission Instructions Submit only the .c and .h files that you created, but do not zip them! Technical Description and Instructions In this project, you will not write a full program. I have already written most of a program to solve randomly generated mazes. The parts that I have written generate the maze and provide functions for interaction with the maze. Additionally, the parts that I have written rely on calling some functions that will solve the maze Implementing those functions is your job! Your Two Files You must create two files for this project: "runner.c" and"runner.h". Runner".h" should expose two functions to the rest of the program called runner solve() and runner_init). The first function will utilize the maze library functions I've provided to solve a maze1. The second function simply performs any setup necessary for the runner_solve() function to run. These two functions should be implemented in the "runner.c" file You may create as many helper functions as necessary to support your runner_solve() function2. Likewise you may use any reasonable algorithm to actually solve the maze. Your runner must leave behind a trail of 'breadcrumbs' as it moves through the maze (see Program Output for details) Program Output Program output is actually handled for you on this one! The maze_runner.c file I've provided for you will call print_maze) for you to show both the unsolved maze and the maze after your runner has finished However, you must accurately show the path that was taken by your algorithm to solve the maze. This is done by using the maze-set-char() function as your runner, moves through the maze. When the runner crosses an empty square, it should leave a '.' behind. When it crosses a '.', it should leave an 'o' behind When an 'o' is crossed, an 'O'3 should result. Finally, when an 'O' is crossed, an 'Q' should be left in its place Descriptions of these maze library functions are in the comments of the mazelib.h file provided 2My implementation has around five. 3Capital 'o', not a zero!  Overview In this project you will implement the logic of a maze solver in C. In the course of this project, you will get more practice with all of the fundamental programmatic structures of C as well as experience using external library code. Finally, you will need to create your first '.h' file to provide an interface to your code. Submission Instructions Submit only the .c and .h files that you created, but do not zip them! Technical Description and Instructions In this project, you will not write a full program. I have already written most of a program to solve randomly generated mazes. The parts that I have written generate the maze and provide functions for interaction with the maze. Additionally, the parts that I have written rely on calling some functions that will solve the maze Implementing those functions is your job! Your Two Files You must create two files for this project: "runner.c" and"runner.h". Runner".h" should expose two functions to the rest of the program called runner solve() and runner_init). The first function will utilize the maze library functions I've provided to solve a maze1. The second function simply performs any setup necessary for the runner_solve() function to run. These two functions should be implemented in the "runner.c" file You may create as many helper functions as necessary to support your runner_solve() function2. Likewise you may use any reasonable algorithm to actually solve the maze. Your runner must leave behind a trail of 'breadcrumbs' as it moves through the maze (see Program Output for details) Program Output Program output is actually handled for you on this one! The maze_runner.c file I've provided for you will call print_maze) for you to show both the unsolved maze and the maze after your runner has finished However, you must accurately show the path that was taken by your algorithm to solve the maze. This is done by using the maze-set-char() function as your runner, moves through the maze. When the runner crosses an empty square, it should leave a '.' behind. When it crosses a '.', it should leave an 'o' behind When an 'o' is crossed, an 'O'3 should result. Finally, when an 'O' is crossed, an 'Q' should be left in its place Descriptions of these maze library functions are in the comments of the mazelib.h file provided 2My implementation has around five. 3Capital 'o', not a zero

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago