Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python please (text file picture is below) Create a program that allows the user to solve a maze that is read in from a

in python please (text file picture is below)

image text in transcribedimage text in transcribedimage text in transcribed

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 1D 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 1D 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: 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. maze - Notepad File Edit View * * 5f

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

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

2. What are the different types of networks?

Answered: 1 week ago