Karel Level 0
Start
Help Karel the robot clean up her world!
Commands
Tell your robot how to complete this level by writing commands. Commands go in the Robot
tab inside the commands
method
void commands() {
// put your robot instructions here!!!
}
Here's a list of the commands you can use.
- move()
- Move the robot forward one square in her current direction.
- A wall must not be directly in front of the robot when moving.
- turnLeft()
- Turn the robot left 90 degrees.
- pickBeeper()
- Tell the robot to pick up a beeper from the world.
- A beeper must exist at the robot's current position.
- putBeeper()
- Tell the robot to put down a beeper at her current position.
- The robot must have beepers in her beeper bag.
- turnOff()
- Stop running commands and print the results.
Errors
If you break the rules of a command, your robot will shut itself down. For example, this set of commands:
void commands() {
move();
move();
move();
}
will cause your robot to shutdown because it may not walk through walls. Here is what that will look like in the world:
and in the console:
Press space to start
Karel is facing East at [1, 1] with 0 beepers.
Karel is facing East at [2, 1] with 0 beepers.
Karel is facing East at [3, 1] with 0 beepers.
Karel !!!Error!!! Tried to walk through a wall!
Goal
This is what it should look like when you have successfully completed the level.
Results
When you turnOff
your robot, it will print information to the console. Compare yours to a typical solution below. If you used a lot more moves or turns, re-think the problem and try to create a more efficient solution.
Moves | 19 |
Turns | 16 |
Puts | 5 |
Picks | 5 |