Showing posts with label Maze. Show all posts
Showing posts with label Maze. Show all posts

Tuesday, July 29, 2014

Solutions: A Maze Using Repeat Loops in Pro-Bot

1.  Assuming that you start at the leftmost corner and facing forward, here is a possible solution for the maze given in the figure:


Rpt 3 [
Fd 12
Rt
]
Fd 2
Rt
Rpt 3 [
Fd 8
Lt
]
Fd 2
Lt
Rpt 3 [
Fd 4
Rt
]



2.  Assuming that you start at the leftmost corner and facing forward, here is a possible solution for the maze given in the figure. The program is same as the one above, with an addition of two more instructions at the end, to draw the solid line at the bottom of the maze.


Rpt 3 [
Fd 12
Rt
]
Fd 2
Rt
Rpt 3 [
Fd 8
Lt
]
Fd 2
Lt
Rpt 3 [
Fd 4
Rt
]
Bk 2
Fd 10


A Maze using Repeat Loops in Pro-Bot: Assignment 2

(1)   Here is a maze that combines parts of 3 squares. All measurements are in centimeters.

The outer section has 12 cm sides. The middle section has 8 cm sides and the inner-most section has 4 cm sides.

Each of the partial squares can be drawn using Repeat Loops in Pro-Bot, as we saw in our previous assignment. Can you write a program for Pro-Bot to draw this figure?

Your program will have three sets of Repeat Loops as well as other instructions in between. So far, all of the programs that you wrote for Pro-Bot used either a sequence of simple instructions or stand-alone Repeat Loops. This is a good example to see a mix of both in a program.






















(2)   This is a follow-up exercise to the above maze. All measurements are in centimeters.

The outer section has 12 cm sides. The middle section has 8 cm sides and the inner-most section has 4 cm sides. Each of the sections can be drawn using Repeat Loops in Pro-Bot, as we saw in our previous assignment.

Can you write a program for Pro-Bot to draw this figure?

Can you modify the previous program for the maze, adding just a couple lines of code, for Pro-Bot to draw this figure?

This is a good exercise in modifying or editing an existing piece of code to create a new functionality.






















Here is a set of solutions.