make_a_maze
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
make_a_maze [2019/08/17 11:25] – frchris | make_a_maze [2019/08/17 11:47] – [3 Ways to Make Walls] frchris | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Make a Maze ====== | ||
+ | Make a Maze with 4 to 6 walls and one beeper. | ||
+ | |||
Walls or obstacles are pared of the World class and can be placed in a NS or a EW direction, and have length. | Walls or obstacles are pared of the World class and can be placed in a NS or a EW direction, and have length. | ||
Line 7: | Line 10: | ||
public class Walls implements Directions { | public class Walls implements Directions { | ||
public static void task() { | public static void task() { | ||
- | Robot | + | Robot |
- | karel.move(); | + | robby.move(); |
- | karel.move(); | + | robby.move(); |
- | karel.pickBeeper(); | + | robby.pickBeeper(); |
- | karel.move(); | + | robby.move(); |
- | karel.turnLeft(); | + | robby.turnLeft(); |
- | karel.move(); | + | robby.move(); |
- | karel.move(); | + | robby.move(); |
- | karel.putBeeper(); | + | robby.putBeeper(); |
- | karel.move(); | + | robby.move(); |
- | karel.turnOff(); | + | robby.turnOff(); |
} | } | ||
Line 24: | Line 27: | ||
World.setDelay(150); | World.setDelay(150); | ||
World.setSize(8, | World.setSize(8, | ||
- | // | ||
World.placeBeepers(1, | World.placeBeepers(1, | ||
World.placeEWWall(3, | World.placeEWWall(3, | ||
Line 33: | Line 35: | ||
} | } | ||
}</ | }</ | ||
- | - You can make a long string and send it all at once to the World:< | + | - You can make a long string and send it all at once to the World. |
- | String hurdles = " | + | String hurdles = " |
- | " | + | " |
- | "northsouthwalls 8 1 1\n" + | + | "eastwestwalls 3 1 3\n" + |
- | " | + | " |
- | "northsouthwalls 2 1 1\n" + | + | "eastwestwalls 6 1 6\n" + |
- | "northsouthwalls 1 1 1"; | + | "beepers |
World.getWorld(hurdles); | World.getWorld(hurdles); | ||
World.setVisible(); | World.setVisible(); | ||
task(); | task(); | ||
}</ | }</ | ||
+ | - You can place a text file with string commands like this: < | ||
+ | streets 8 | ||
+ | avenues 9 | ||
+ | beepers 1 4 1 | ||
+ | eastwestwalls 3 1 3 | ||
+ | northsouthwalls 1 6 5 | ||
+ | eastwestwalls 6 1 6</ |
make_a_maze.txt · Last modified: 2021/09/05 13:16 by frchris