See attached

profileGregmn
homework_1.pdf

Homework 1: Algorithmic

Design

EE 222 • 20 Points Total

Due Wednesday, January 25, 2017

Assignment

Given a grid maze similar to the following:

1 1 1 1 1 1 1

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6

0 # # # # # # # # # # # # # # # # #

1 # # #

2 # # # # # # # # # # # # #

3 # # # # # #

4 # # # # # # # # # # # #

5 # # # # # #

6 # # # # # # # # # # # # #

7 # # # # #

8 # # # # # # # # # # # # #

9 # # #

10 # # # # # # # # # # # # # # # # #

design an algorithm and give the pseudo code to step through the maze starting at

position (1, 1) and get to position (xMax -1, yMax -1). Remember to keep it

generic, so don’t use the example’s dimensions in favor of xMax and yMax. Show

that your algorithm works by tracing its steps, using the example maze for your

demonstration.

‘robot’ knows x,y position and facing(North, South, East, or West)

Commands given in class:

isWallInFront (abbreviated isWall) returns T if there is a wall in the next

space in the facing direction, otherwise F.

atDestination returns T if x,y == position(xMax-1, yMax -1), otherwise F.

turnLeft (abbreviated TL) changes facing 90 degrees counter-clockwise.

turnRight (abbreviated TR) changes facing 90 degrees clockwise.

moveForward (abbreviated Move or Step) changes the x,y position by 1 in

the facing direction.

if (condition){} If the condition is true, do what is in the brackets, no

loopback.

while (condition) {} If the condition is true, do what is in the brackets and

loopback.