The empty pair of parentheses that appears in each of these commands is part of the common syntax shared by Karel and Java and is used to specify the invocation of the command. Karel cannot respond to a putBeeper() command unless there are beepers in its beeper bag. PutBeeper()Asks Karel to take a beeper from its beeper bag and put it down on the current corner. Karel cannot respond to a pickBeeper() command unless there is a beeper on the current corner. PickBeeper()Asks Karel to pick up one beeper from a corner and stores the beeper in its beeper bag, which can hold an infinite number of beepers. TurnLeft()Asks Karel to rotate 90 degrees to the left (counterclockwise). Karel cannot respond to a move() command if there is a wall blocking its way. Move()Asks Karel to move forward one block. When Karel is shipped from the factory, it responds to a very small set of commands:
Karel’s world is always bounded by walls along the edges, but the world may have different dimensions depending on the specific problem Karel needs to solve. Karel cannot walk through walls and must instead go around them. Walls serve as barriers within Karel’s world. The solid lines in the diagram are walls. As described in Rich Pattis’s book, beepers are “plastic cones which emit a quiet beeping noise.” Karel can only detect a beeper if it is on the same corner. The object in front of Karel is a beeper. Several other components of Karel’s world can be seen in this example. Here Karel is located at the corner of 1st Street and 1st Avenue, facing east. Karel can only be positioned on corners and must be facing one of the four standard compass directions (north, south, east, west). The intersection of a street and an avenue is called a corner. “Karel’s world is defined by streets running horizontally (east-west) and avenues running vertically (north-south). Initially, Karel understands only a very small number of predefined commands, but an important part of the programming process is teaching Karel new commands that extend its capabilities.” The process of specifying those commands is called programming. By giving Karel a set of commands, you can direct it to perform certain tasks within its world. “Karel is a very simple robot living in a very simple world. In addition, Karel makes use of Eclipse, the same IDE we’ll be programming our robots in. Karel provides a basic introduction to the programming language we’ll be using for Robotics. Named after Karel Capek, the Czech playwright, Karel is a program (software and curriculum) designed by Stanford.
Simplicity is prerequisite for reliability.Ĭouple things to do today.