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


No comments:

Post a Comment