Create a program that allows the user to solve a maze that is read in from...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create a program that allows the user to solve a maze that is read in from a file. The user will begin at the starting point ('s') of the maze and will be able to move up, down, left, or right to move through the maze. When the user reaches the finish (f), they have solved the maze. Create the following functions for your program: 1. read maze () - read in the contents of the file and store the contents in a 2D list. Each character in the maze (make sure to keep all the spaces, but you can strip out the new lines if necessary) should be stored in a separate element in the 2D list (note: this function should work for any size maze, not just the 9x15 provided). Return the filled 2D list. 2. find start (maze) - passes in the filled maze (of any size). Search through the elements in the maze using a set of nested for loops to find an 's'. Return the location as a two item ID list where the first item is the row, and the second item is the column. 3. display_maze (maze, loc) -passes in the filled maze (of any size) and the user's location. Iterate through the contents of the maze. Display each character in the maze in a matrix format. When you reach the user's location, display an 'X' instead so that it shows where the user is in the maze (do not actually place the 'X' in the 2D list, just display it). In the main function, you should have a loop with a menu that repeatedly prompts the user to move in a direction until the user finds the finish. The user will have a two item ID list that stores the row and column of their location in the maze that is initialized to the start position of the map. Move the user by updating the row and column values in the location list by adding or subtracting 1 to the row or column (depending on the direction they moved). Do not allow the user to move through any walls (*), check the maze at the location the user is moving to see if it is a wall, if it is, display a message that they cannot move there and do not update the user's location. Display the maze each time the user moves. When the user finds the finish, display a congratulatory message and end the program. Example Output: -Maze Solver- -E 1. Go North 2. Go South 3. Go East 4. Go West Enter choice: f Invalid input should be an integer. Enter choice: 2 You cannot move there. 1. Go North 2. Go South 3. Go East 4. Go West Enter choice: 1 - fx 1. Go North 2. Go South 3. Go East 4. Go West Enter choice: 4 ******* *X Congratulations! You solved the maze. Notes: 1. Please place your name, date, and a brief description in a comment block at the top of your program. 2. Use the check_input module provided on Canvas to check the user's input for invalid values. Add the py file to your project folder to use the functions. You may modify it as needed. Examples using the module is provided in a reference document on Canvas. 3. Do not create any extra functions or add any extra parameters. 4. Please do not create any global variables, instead, pass variables as arguments to the functions and return values back when needed. 5. Please read through the Coding Standards reference document on Canvas for guidelines on how to name your variables and to format your program. 6. Use docstrings to document each of your functions. Document all parameters and return values. Add brief comments in your program to describe sections of code. 7. Thoroughly test your program before submitting: a. Make sure that the file is read in correctly and each character is stored in a separate element in the 2D list. b. Make sure that you don't mix up the rows and columns of the 2D list. c. Make sure that your maze is displayed correctly (ie. properly oriented). d. Make sure that the user begins at the start position. e. Make sure that all user input is checked for invalid values. f. Make sure that the user correctly moves in the direction specified. g. Make sure that the user cannot move through walls in any direction. h. Make sure that the program ends when the user finds the finish. Create a program that allows the user to solve a maze that is read in from a file. The user will begin at the starting point ('s') of the maze and will be able to move up, down, left, or right to move through the maze. When the user reaches the finish (f), they have solved the maze. Create the following functions for your program: 1. read maze () - read in the contents of the file and store the contents in a 2D list. Each character in the maze (make sure to keep all the spaces, but you can strip out the new lines if necessary) should be stored in a separate element in the 2D list (note: this function should work for any size maze, not just the 9x15 provided). Return the filled 2D list. 2. find start (maze) - passes in the filled maze (of any size). Search through the elements in the maze using a set of nested for loops to find an 's'. Return the location as a two item ID list where the first item is the row, and the second item is the column. 3. display_maze (maze, loc) -passes in the filled maze (of any size) and the user's location. Iterate through the contents of the maze. Display each character in the maze in a matrix format. When you reach the user's location, display an 'X' instead so that it shows where the user is in the maze (do not actually place the 'X' in the 2D list, just display it). In the main function, you should have a loop with a menu that repeatedly prompts the user to move in a direction until the user finds the finish. The user will have a two item ID list that stores the row and column of their location in the maze that is initialized to the start position of the map. Move the user by updating the row and column values in the location list by adding or subtracting 1 to the row or column (depending on the direction they moved). Do not allow the user to move through any walls (*), check the maze at the location the user is moving to see if it is a wall, if it is, display a message that they cannot move there and do not update the user's location. Display the maze each time the user moves. When the user finds the finish, display a congratulatory message and end the program. Example Output: -Maze Solver- -E 1. Go North 2. Go South 3. Go East 4. Go West Enter choice: f Invalid input should be an integer. Enter choice: 2 You cannot move there. 1. Go North 2. Go South 3. Go East 4. Go West Enter choice: 1 - fx 1. Go North 2. Go South 3. Go East 4. Go West Enter choice: 4 ******* *X Congratulations! You solved the maze. Notes: 1. Please place your name, date, and a brief description in a comment block at the top of your program. 2. Use the check_input module provided on Canvas to check the user's input for invalid values. Add the py file to your project folder to use the functions. You may modify it as needed. Examples using the module is provided in a reference document on Canvas. 3. Do not create any extra functions or add any extra parameters. 4. Please do not create any global variables, instead, pass variables as arguments to the functions and return values back when needed. 5. Please read through the Coding Standards reference document on Canvas for guidelines on how to name your variables and to format your program. 6. Use docstrings to document each of your functions. Document all parameters and return values. Add brief comments in your program to describe sections of code. 7. Thoroughly test your program before submitting: a. Make sure that the file is read in correctly and each character is stored in a separate element in the 2D list. b. Make sure that you don't mix up the rows and columns of the 2D list. c. Make sure that your maze is displayed correctly (ie. properly oriented). d. Make sure that the user begins at the start position. e. Make sure that all user input is checked for invalid values. f. Make sure that the user correctly moves in the direction specified. g. Make sure that the user cannot move through walls in any direction. h. Make sure that the program ends when the user finds the finish.
Expert Answer:
Answer rating: 100% (QA)
Answer The code for the above program is def readmaze maze with openmazetxt r as file for line in fi... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
2. Construct a station model (weather symbol) to show the following: DRY BULB TEMPERATURE = 12C DEW POINT TEMPERATURE = 5C WIND 15 km/h from the northwest = CLOUD COVER = 3/10 dense cirrus in...
-
In this assignment, you will create a program that allows theuser to draw in a window using brushes of different sizes andcolors. The user will be able to change the size and color of thebrush using...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Given the following marginal utility schedule for good X and good Y for an individual A, given that the price of X and the price of Y are both $10, and that the individual spends all his income of...
-
The acceleration due to gravity on Mars is 3.75 m/s2. Knowing that the mass of a silver bar has been officially designated as 20 kg, determine, on Mars, its weight in newtons.
-
Write a C++ preorder iterator to supply tree nodes to the loop in Example 6.69. You will need to know (or learn) how to use pointers, references, inner classes, and operator overloading in C++. For...
-
Discuss the theoretical bases for the four HR administrative approaches introduced in this chapter. Are such theories useful to HR professionals in their efforts to improve transactional performance?...
-
Winter Companys balance sheet at December 31, 2014, is presented below. During January 2015, the following transactions occurred. Winter uses the perpetual inventory method. Jan. 1 Winter accepted a...
-
While taking the measurement of a different sphere with a radius of r = 2 . 2 2 cm , your instrument has a measurement uncertainty of \ pm 0 . 0 4 cm . What is the propagated uncertainty of the...
-
Create and Format a Table 1. Open VRSeries.xlsx and save it with the name 3-VRSeries. 2. Select the range A3:K34 and create a table. The table has headers. 3. Name the table Inventory. 4. Apply the...
-
Matthew is a single taxpayer and qualifies for the earned income credit. he has two qualifying children his wages are $18,900 and receives dividends income of $900 what is the earned credit income...
-
Help your team understand emotional intelligence and how it will impact the team's effectiveness by doing the following in the next portion of your presentation: a. Discuss the importance of...
-
What can you say about this? in a conversational way The Philippines, being situated in the Ring of Fire, is vulnerable to typhoons, earthquakes, and volcanic eruptions. This is why it is important...
-
Compare and contrast the historical development and roles of employer associations in employment relations in the UK and USA. Make sure to identity and discuss the similarities and main differences....
-
What can you say? in a conversational way. As an educator, I believe that through these initiatives education, on environmental sustainability is key to building a sustainable future. Educating...
-
The HRPA Code of Ethics and Rules of Professional Conduct identifies Competence obligations. Explain the term and identify how it would apply to the VP and Director of HR in this setting.
-
The accounts of Delphinia? Dreams, Inc. showed the followingbalances at the beginning of? October: Account Debit : Raw Materials Inventory $30,000 Work in Process Inventory 44,000 Finished Goods...
-
Prove that the mean heat capacities C P H and C P S are inherently positive, whether T > T 0 or T < T 0 . Explain why they are well defined for T = T 0 .
-
This exercise is the same as Programming Exercise 1, except that you should use private inheritance instead of containment.Again, a few typedefs might prove handy. Also you might contemplate the...
-
Why didnt the STL designers simply define a base iterator class, use inheritance to derive classes for the other iterator types, and express the algorithms in terms of those iterator classes?
-
Rewrite the Stock class, as described in Listings 10.7 and 10.8 in Chapter 10 so that it uses dynamically allocated memory directly instead of using string class objects to hold the stock names. Also...
-
Determine the most appropriate strategy that can generate liquidity and accomplish Omos goals. Justify your response. Jing asks Omo about his plans for the shares of his previous employers company....
-
Discuss four important risk and tax-related considerations that are relevant to Omos portfolio. With most of Omos personal net worth tied up in his software company, he is asset rich but cash poor....
-
Recommend, for both Enlows niece and nephew, the most tax-efficient wealth transfer option (lifetime gift or testamentary bequest). Show your calculations. Recommend, for both Enlow's niece and...
Study smarter with the SolutionInn App