Monday Sections HX, KX 27 November 2000 Thursday Section RY 30 November 2000 EEN118 LAB TWELVE A few weeks ago, in lab ten, you wrote a program that lets a human user control the computer’s exploration of a maze. Today you will be experimenting with auomatic exploration, the beginning of artificial intelligence. It is perfectly acceptable to modify and re-use any of the programs you may already have written. This lab also gives you a little experience of programming with objects. 1. Make sure it Still Works. You should already have a program that reads in a maze as illustrated below (height, width, starting row, starting column, then the maze picture), and draws it using the graphics.h library functions. Make sure that you remember how it works. Example maze in the style of lab ten: 10 20 1 1 XXXXXXXXXXXXXXXXXXXX X X XX X X XX XX XXX X X X X X XX X X XX X X XX X XXX XX X XX XXXXXX XXXXX X X XX XXXX XX XXXXXX XX XXX XX X XX X XXXXXXXXXXXXXXXXXXXX However, this week, the maze descriptions will be slightly different. The input will consist of the maze-picture alone, no numbers. The program will have to work out how big the maze is for itself. That is actually quite easy, and because you have already programmed something very much like it before, I’ll give you most of the program here: #include struct mazedata { int map[50][50]; int rows, cols; }; That definition creates a new kind of object, called a “mazedata”. Any mazedata variable will have three components called “map”, “rows”, and “cols”. Grouping them into a single object makes it convenient and efficient to pass all the information about a maze into a function with a single parameter. I hope you remember all that from class. Note how the function readmaze (below) is defined. It only has one parameter, but that parameter is a whole mazedata object, so all three components are received at once. Remember that the & in front of the parameter’s name) which makes it into a Reference Parameter) is needed if the function is allowed to modify the parameter, but it also improves efficiency. void read_maze(mazedata &m) { m.rows=0; m.cols=0; int r, c; for (r=0; r<50; r+=1) { for (c=0; c<50; c+=1) { m.map[r][c]=-1; } } for (r=0; r<50; r+=1) { string s=read_line(); int linelength=s.length(); if (linelength==0) break; m.rows+=1; if (linelength>m.cols) m.cols=linelength; for (c=0; c