Unit1, Lab18: Treasure Hunt

map1

map2

map3

Algorithm for Reading a Map

1.  Continue forward until you encounter a pile of beepers.

2.  If you are at a pile with exactly five beepers, you’ve found the treasure.

3.  Otherwise, if there is exactly one beeper, then turn left.

4.  Otherwise, if there are exactly two beepers, then turn around.

5.  Otherwise, if there are exactly three beepers, then turn right.

5.  Otherwise, maintain your current heading.

6.  Repeat as needed.


Files: Unit1\Lab18.java;  Classes: Pirate, World;  Worlds: 10x10;  Page: One-51

Back to Unit1