1 / 30

Project 5: Labyrinth

Project 5: Labyrinth. The Labyrinth. The abby library in The Name of the Rose is a labyrinth of 56 rooms. We need to provide a reliable method for finding one's way to any room from the entrance point. The Library. Map of the Library as shown on page 321.

alaina
Download Presentation

Project 5: Labyrinth

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Project 5: Labyrinth

  2. The Labyrinth • The abby library in The Name of the Rose is a labyrinth of 56 rooms. • We need to provide a reliable method for finding one's way to any room from the entrance point.

  3. The Library Map of the Library as shown on page 321

  4. We went through other rooms, recording all our discoveries on my map. We came upon rooms devoted soley to writings on math- The Library's Classification System 320

  5. Identifying the Rooms • The library consists of four symmetrical quadrants, each consisting of 14 rooms. • The letters shown in most rooms are significant to the story, but not to the problem at hand. (They do not uniquely identify the rooms.) • As an aid to navigating the library, we have divided the map into quadrants and systematically assigned numbers to the rooms in each quadrant.

  6. East 7 2 1 1 6 3 7 8 2 5 14 8 4 9 3 4 5 6 13 10 12 11 11 12 9 14 10 13 13 14 10 12 9 11 11 12 13 10 5 4 3 6 14 9 4 5 2 8 8 7 3 6 1 1 2 7 West South Rooms Numbered by Quadrant North Rooms numbered by quadrant

  7. Navigating the Labyrinth • The librarians enter the library from the floor below in room 1 of the East quadrant. • We need a systematic way to get to any other room from that room.

  8. Navigating the Labyrinth • Fortunately, Drozdek has provided an algorithm in section 4.7, starting on page 159. • We will adapt his algorithm to the somewhat more irregular geometry of the abby library. This algorithm does not show the mouse going through previously visited cells when backtracking.

  9. Navigating the Labyrinth • Algorithm revised to show backtracking • Also reworded for the library maze • Initialize stack, destination room, current room = E1 • Mark current room as seen. • While current room is not destination room • Output current room name • For each previously unseen adjacent room • Push current room onto the stack • Push the adjacent room onto the stack and mark it as seen. • If stack is empty, report failure. • else pop room from stack and set as current room. • Report success.

  10. Data File • The map shows which rooms are connected to which. That information has been coded as a comma separated values file, maze.csv, available in the Downloads area of the class web site: • http://www.cse.usf.edu/~turnerr/Data_Structures/Downloads/Labyrinth/maze.csv • There are 56 lines in the file, corresponding to the 56 rooms of the library. • The first thing in each line is a room ID. Following are the IDs of all rooms that can be reached from that room.

  11. Initial Lines of Data File • The first line says that from room N1 one can move to rooms N2 and N7. • The eighth line says that from room N8 one can move to rooms N2, N3, N4, N5, and N6. • No more than five rooms are directly reachable from any given room. • There are extra commas at the end of some lines

  12. Specifications • Use the DLList and Stack templates that we have developed in class. • Both are available in the Downloads area. • Use these files exactly as provided. • DLList has been modified slightly to meet needs of this project. • The get method has been changed to return a normal non-constant reference. • We can now use the reference to modify the item to which it refers. • A get_pos() method has been added. • Returns a reference to the data stored at a specified position within the list. • printAll() now has an ostream& parameter.

  13. Specifications • Create a Room class to hold the information that we know about each room: • Name • Adjacent rooms. • It should have a boolean member that can be set to show that the room has been visited seen. • Read the CSV file and create a list of Room objects as the description of the labyrinth.

  14. Specifications • Don't hard code information about the labyrinth in your program • Other than the fact that there are 56 rooms and a maximum of five rooms are reachable from any given room. • The data file has at least six commas on every line. • Some lines have extra commas at the end. • There is a comma following each room ID.

  15. User Interface • Prompt the user for a destination room number. • Output the name of each room visited as you navigate the labyrinth according to Drozdek's the revised algorithm. • Upon completion output a message telling the user whether or not you were able to reach the specified destination room.

  16. Sample Run: E14 Drozdek's Algorithm

  17. Sample Run: E3 Drozdek's Algorithm Backtracking not shown Backtracking not shown Continued on next slide

  18. Sample Run: E3 (continued) Drozdek's Algorithm

  19. Sample Run: S8 Drozdek's Algorithm Continued on next slide

  20. Sample Run: S8 (continued) Drozdek's Algorithm

  21. Sample Run: E14 Revised Algorithm Same result for this case. (There was no backtracking.)

  22. Sample Run: E3 Revised Algorithm

  23. Sample Run: E3 Revised Algorithm

  24. Sample Run: E3 Revised Algorithm

  25. Sample Run: S8 Revised Algorithm

  26. Sample Run: S8 Revised Algorithm

  27. Sample Run: S8 Revised Algorithm

  28. Ground Rules You may work with one other person. OK to work alone if you prefer. If you do work as a pair Both members are expected to contribute. Submit a single program. Both members should understand the program in detail. Do not share your work with other students. Before or after submitting the project. OK to discuss the project. Do not copy any other student’s work. Don’t look at anyone else’s program. 28 28

  29. Ground Rules Except for code posted on the class web site Do not copy code from the Internet or any other source. Write your own code. 29

  30. Submission Project is due by 11:59 PM, Tuesday, Feb. 22 Friday, Feb 25 Deliverables: Source code only. Room.h, Room.cpp, main.cpp We will provide DLList.h and Stack.h (from the Downloads area) Zip your source code files using the Windows “Send to Compressed Folder” command. Submit the zipped file via Blackboard Assignments. If you work with another student, include both names in the assignment comments. Other student submit assignment with just a Blackboard comment including both names. End of Presentation 30 30

More Related