25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 1. Your program should only process this plain text file with the data and format: 2. The first line of the file contains two integers representing the number of rows and the number of columns (in that order) of the maze. Read these two numbers and save them in two variables: Row and Column, respectively. 3. The next Row lines (where Row is the number of rows) will contain Column integer values (where Column is the number of columns) containing 1 and 0 separated by a space. 4. A 1 represent a wall and a 0 represents a space (can be moved to and from) in the maze. C: > Users > moses > Downloads > C maze.c> main() 1 // This is an example of the Maze project framework, it is not a working project. 2 // You need to complete this code. 3 // please finish the function printMap and updateMap to make the maze project work. #include 4 5 #include 6 // The global variables. 7 int rows, columns; 8 int charx, chary; 9 48 49 5. 6. 10 // This function is to udpate the array map after each cursor movement. 11 updateMap (int map[][], const char choice) { 12 } 13 14 15 16 17 18 19 20 21 22 23 24 50 51 52 53 54 55 56 57 58 The single "2" represents the location of the end point. When you print this map in the code, 1 should be replaced by 'l' and 0 should be replaced by " (space). The current location of the robot should print 'C', and the target should print 'E'. // This function is to print/draw the map. void printMap (const int map[rows][columns], const int charx, const int chary){ } // This function is to find the initial Location of the car and update the global variables // charx and chary findInitialPosition (const int map[rows] [columns]) { } int main(){ FILE* in = fopen("mapData.txt","r"); int x,y,done=0; char choice; // load the map // Step 1: Read the maze rows and columns from the mapData.txt file, you need to read the file. // The map will be stored in a 2-dimensional array. int map[rows] [columns]; // Step 2: Find the initial location of the car. findInitialPosition (map); //printf ("The Maze has %d rows %d columns \n", rows, columns); // Test Code //printf ("The car starts at row %d and column %d\n", charx, charY); // Test Code // Step 3: Read the nput to the two-dimensional array map, using fscanf and loops // load map finished // Step 4: use function printMap to print the Map on the screen. printMap (map, charx, charY); // charx, chary is the new location. while (done==0) { printf ("This code is designed by _your_names_ \n"); // Display your name on the screen. printf("Press w,a,s,d to move the car up, left down and right..."); choice=getch(); // Get the keyboard input done=updateMap (map, choice); // in this function, it should update the map array for the current cursor positions // when the input is valid (w,a,s,d). // also, should make done = 1 if the cursor is moved to the end point E. system("cls"); // this is a windwos-only function to clean the screen. // For Mac, please check some reference to clean the screen. printMap (map, charx, charY); // print the map after each valid movement. printf ("\n Maze Solved!!! \n"); // problem solved if done is not 0. fclose(in); // close the file. system("pause"); return 0; Sample format (mapData.txt): 10 8 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 1 1 0 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 1 0 1 1 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 0 0 0 1 1 0 1 0 1 1 1 1 1 0 1 0 0 0 2 1 1 1 1 1 1 1 1 1 Your code should move the cursor to the starting point located at the first 0 from the top and left border, and then use w, a, s, or d keys to control it to move to E. When E is reached, your code will print a message on the screen "Maze solved!!!" Please notice that part of the code is already provided, and you need to understand the code and finish it.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 1. Your program should only process this plain text file with the data and format: 2. The first line of the file contains two integers representing the number of rows and the number of columns (in that order) of the maze. Read these two numbers and save them in two variables: Row and Column, respectively. 3. The next Row lines (where Row is the number of rows) will contain Column integer values (where Column is the number of columns) containing 1 and 0 separated by a space. 4. A 1 represent a wall and a 0 represents a space (can be moved to and from) in the maze. C: > Users > moses > Downloads > C maze.c> main() 1 // This is an example of the Maze project framework, it is not a working project. 2 // You need to complete this code. 3 // please finish the function printMap and updateMap to make the maze project work. #include 4 5 #include 6 // The global variables. 7 int rows, columns; 8 int charx, chary; 9 48 49 5. 6. 10 // This function is to udpate the array map after each cursor movement. 11 updateMap (int map[][], const char choice) { 12 } 13 14 15 16 17 18 19 20 21 22 23 24 50 51 52 53 54 55 56 57 58 The single "2" represents the location of the end point. When you print this map in the code, 1 should be replaced by 'l' and 0 should be replaced by " (space). The current location of the robot should print 'C', and the target should print 'E'. // This function is to print/draw the map. void printMap (const int map[rows][columns], const int charx, const int chary){ } // This function is to find the initial Location of the car and update the global variables // charx and chary findInitialPosition (const int map[rows] [columns]) { } int main(){ FILE* in = fopen("mapData.txt","r"); int x,y,done=0; char choice; // load the map // Step 1: Read the maze rows and columns from the mapData.txt file, you need to read the file. // The map will be stored in a 2-dimensional array. int map[rows] [columns]; // Step 2: Find the initial location of the car. findInitialPosition (map); //printf ("The Maze has %d rows %d columns \n", rows, columns); // Test Code //printf ("The car starts at row %d and column %d\n", charx, charY); // Test Code // Step 3: Read the nput to the two-dimensional array map, using fscanf and loops // load map finished // Step 4: use function printMap to print the Map on the screen. printMap (map, charx, charY); // charx, chary is the new location. while (done==0) { printf ("This code is designed by _your_names_ \n"); // Display your name on the screen. printf("Press w,a,s,d to move the car up, left down and right..."); choice=getch(); // Get the keyboard input done=updateMap (map, choice); // in this function, it should update the map array for the current cursor positions // when the input is valid (w,a,s,d). // also, should make done = 1 if the cursor is moved to the end point E. system("cls"); // this is a windwos-only function to clean the screen. // For Mac, please check some reference to clean the screen. printMap (map, charx, charY); // print the map after each valid movement. printf ("\n Maze Solved!!! \n"); // problem solved if done is not 0. fclose(in); // close the file. system("pause"); return 0; Sample format (mapData.txt): 10 8 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 1 1 0 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 1 0 1 1 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 0 0 0 1 1 0 1 0 1 1 1 1 1 0 1 0 0 0 2 1 1 1 1 1 1 1 1 1 Your code should move the cursor to the starting point located at the first 0 from the top and left border, and then use w, a, s, or d keys to control it to move to E. When E is reached, your code will print a message on the screen "Maze solved!!!" Please notice that part of the code is already provided, and you need to understand the code and finish it.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
This is an example of the Maze project framework, it is not a working project.
You need to complete this code.
Please finish the function printMap and updateMap to make the maze project work.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education