This page provides a reference guide that describes the details of the commands
and functions that Karel understands.
You may also want to read an overview of Karel's world
and what it can do..
Karel's ACTION Functions:
- move()
-
Move Karel forward exactly one position, in the direction it is facing.
If Karel hits a wall, that is considered a program error!
- turnRight()
-
Turns Karel 90 degrees clockwise.
- pickBeeper()
-
Karel will pick up a beeper at the current intersection and place it in its backpack.
If there is no beeper on the ground at that intersection
to pick up, that is considered a program error!
- putBeeper()
-
Karel will take a beeper out of its backpackage, and
place it on the ground at the current intersection.
If Karel's backpack is empty, then Karel obviously cannot fulfill this
instruction; that is considered a program error!
Karel's SENSOR functions:
Karel understands many built-in sensor-input functions which return information
about the outside world (e.g. which direction Karel is facing, whether there is a wall in
front of Karel, etc.) All of the functions that
begin with 'is' return either true or false, boolean values which can be tested directly within
an 'if' or 'while' statement.
- isFacingNorth(), isFacingSouth(), isFacingEast(), isFacingWest()
-
Each returns true if Karel is facing the corresponding direction and returns false otherwise.
- isFrontBlocked(), isLeftBlocked(), isRightBlocked()
-
Each returns true if a wall or boundary is in front of, to the left of, or to the right of
Karel, respectively, or returns false otherwise. These are the opposites of the isXXXClear()
functions.
- isFrontClear(), isLeftClear(), isRightClear()
-
Each returns true if a wall or boundary is NOT in front of, to the left of, or to the right of
Karel, respectively, or returns false otherwise. These are the opposites of the isXXXBlocked()
functions.
- isNextToABeeper(), isNotNextToABeeper()
-
These sensor functions lets your program check to see
if there is at least one beeper on the ground at the
intersection where Karel currently stands.
- isAnyBeepersInBackpack(), isNoBeepersInBackpack()
-
These sensor functions lets your program check to see
if Karel has any beepers in its backpack.