Need help with python. I have no idea what to do. Please do it for me. Also , professor asked us to write comment explaining what the code is doing for every code that you use.?

Simon Fraser University
School of Computing Science

Cmpt 120 ? Assignment 4

Objective
Our objective, in this Assignment 4, is to ?

solving a problem by developing (using Python building blocks learnt so far), testing and
debugging, in an incremental fashion, a Python program,
investigating and discovering new Python building blocks,
and having fun along the way.

Problem Statement
Over our next two assignments, we shall build our own version of the game Mario. Well, a
simple TUI version. TUI means Text-based User Interface or Textual User Interface as opposed
to GUI, which stands for Graphical User Interface.
The goal of our Assignment 4 is to set up our game, i.e., set up the maze Mario is meant to travel
through. This maze will contain obstacles, Mario himself and an exit gate. The goal of our
Assignment 5 will be to allow the user to play our game by moving Mario around the maze.
Let?s start with Assignment 4, shall we. In order to develop our Assignment 4 in an incremental
fashion, I propose the following scheme: considering the algorithm below, let?s develop, test and
debug each of its steps, one at a time, and move on to the next step only when the step we have
been working on is completed. Here is our algorithm:
1. Welcome the user.
2. Create a maze with a width of mazeWidth and a height of mazeHeight.
a. Assign the value 15 to the variable mazeWidth and the value 12 to the variable
mazeHeight. Note that the values of these two variables will change, so let?s
make sure we develop our program such that modifying the values of these
variables can be done easily.
b. Originally, each cell must contain this string &quot; . &quot;. Note that the content of our
cells will change, so let?s make sure we develop our program such that we can
easily change the content of our cells.
3. Display a boundary around our maze.

a. Originally, we must use the &quot;-&quot; symbol to create the top and the bottom parts of
the boundary around our maze. Note that this symbol will change, so let?s make
sure we develop our program such that we can easily change this symbol.
b. Originally, we must use the &quot;|&quot; symbol to create the side sections of the
boundary around our maze. Note that this symbol will change, so let?s make sure
we develop our program such that we can easily change this symbol. The side
sections of the boundary may be tricky to construct! Suggestion: One way to build
them is to create a string for each of the row of our maze. This string will contain
blank spaces, a number (see 4. b. below), 2 symbols indicating a side section of
the boundary and the actual row of our maze.
c. This boundary is not part of our maze, it is outside our maze.
4. At the top and left of the boundary, display numbers. These numbers will help the user to
select a cell in our maze.
a. To produce the top row of numbers, we can build and print a string that will be
made of blank spaces and numbers.
b. To produce the left-side column of numbers may be tricky! See the suggestion
described in 3. b. above.
5. Add aNumOfRewardingObstacles of rewarding obstacles to our maze.
a. Assign the value 20 to aNumOfRewardingObstacles. Note that this number
will change, so let?s make sure we develop our program such that we can easily
change this number.
b. Originally, we must use the symbol &quot;R&quot; to indicate that a cell of our maze
contains a rewarding obstacle. Note that this symbol will change, so let?s make
sure we develop our program such that we can easily change this symbol.
c. All these obstacles must be randomly located in our maze.
d. We cannot position more than 1 obstacle (of any types) in a cell.
6. Add aNumOfExplodingObstacles of exploding obstacles to our maze.
a. Assign the value 20 to aNumOfExplodingObstacles. Note that this number
will change, so let?s make sure we develop our program such that we can easily
change this number.
b. Originally, we must use the symbol &quot;E&quot; to indicate that a cell of our maze
contains an exploding obstacle. Note that this symbol will change, so let?s make
sure we develop our program such that we can easily change this symbol.
c. All these obstacles must be randomly located in our maze.
d. We cannot position more than 1 obstacle (of any types) in a cell.
The image below represents the result of the above 6 steps:

7. Ask the user for Mario?s initial location in the maze.
a. Let?s make sure that the user has entered a location that makes sense:
i. The user has entered 2 integers separated by a blank space. The user has
1. not simply pressed the Enter key, or
2. entered a string, or
3. entered 1 integer or 1 float, or
4. entered 2 numbers of which one or both are floats, or
5. entered more than 2 integers or floats.
ii. The row number entered by the user does not exceed the maximum
number of rows of our maze.
iii. The column number entered by the user does not exceed the maximum
number of columns of our maze.
iv. Finally, the user has entered the row number and column number of an
empty cell.
b. Add Mario at that location. Originally, we must use the symbol &quot;M&quot; to indicate
the location of Mario in our maze. Note that this symbol will change, so let?s
make sure we develop our program such that we can easily change this symbol.
The Sample Run 1, posted on our course web site below the description of this
assignment, illustrates how the program responds to the user when s/he has entered
invalid data described in the step (7.) above.
8. Based on Mario?s location, our program is to place the exit gate on the top or bottom part
of our boundary according to the following rule:
a. Imagine we divide our maze into 4 quadrants: top right, top left, bottom right,
bottom left.

i. If the user has placed Mario in the top right quadrant, then our program
positions the exit gate on the bottom section of the boundary to the left of
the median (imaginary vertical line dividing our maze in two).
ii. If the user has placed Mario in the top left quadrant, then our program
positions the exit gate on the bottom section of the boundary to the right of
the median.
iii. If the user has placed Mario in the bottom right quadrant, then our
program positions the exit gate on the top section of the boundary to the
left of the median.
iv. If the user has placed Mario in the bottom left quadrant, then our program
positions the exit gate on the top section of the boundary to the right of the
median.
b. Originally, we must use the symbol &quot;=&quot; to indicate the exit gate on the top or
bottom part of the boundary of our maze. Note that this symbol will change, so
let?s make sure we develop our program such that we can easily change this
symbol.
The image below represents the result of the above 8 steps:

Please, have a look at the Sample Runs posted on our course web site.
The code we create for Assignment 4 must produce exactly the same output as the one shown
in the images included above and the Sample Runs. Of course, the position of our obstacles
(both types), of Mario and of the exit gate will be different but everything else must be the
same.

Caution
Remember that indices of list elements start at 0, while the numbers displayed above and to the
left of our maze start at 1. Therefore, when the user selects the cell in which Mario is to be

placed on our maze, once we read these two numbers (the row and column numbers), we may
have to decrement them by 1 in order to use these numbers as indices.

Submission

Submit our file: My_Mario_Version_1.py on CourSys by Friday, March 18, 2016,
15:30.
o Make sure we remove or comment out our debugging print statements before
submitting our program.

We can submit our work to CourSys as many times as we wish, but it is the last
submission that counts. So, let's make sure that our last submission is done before the

No late submission will be accepted: any submission made after the due date and time
stated above will not be marked for grades. However, they will be marked to provide
feedback to students.
o The only exception is for medical reasons. If we are not able to submit our
assignment on time due to a medical reason, we must notify the instructor by
email right away and provide her with a doctor?s note as soon as possible.

Marking
When marking Assignment 4, we will look at how well our solution satisfies the description and
requirements of this assignment as described in the problem Statement section above as well as
the criteria listed here:

How well are we abiding to the Good Programming Style items described on the GPS
web page of our course web site?

Have we created functions?
o Have we developed our solution using the following guidelines:
Decomposition
Encapsulation
Function interface design:
Is each of our functions performing one main (well-defined)
action, i.e., it has one purpose?
Does the name of each of our functions describe the main action or
purpose performed by this function?
Generalization

o Are our functions called from the ?# Main? section of our program or from our
user-defined functions? Bottom line: all our functions must be called at least once.
o Have we use docstring when implementing our functions (have a look at our
textbook for an explanation and an example).

Whether or not the program executes: are there any syntax and/or runtime errors?

Whether or not the program solves the problem: are there any semantic errors?

Have fun!

Anne Lavergne ? March 2016