ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Robot Karel


Enviado por   •  18 de Marzo de 2015  •  874 Palabras (4 Páginas)  •  193 Visitas

Página 1 de 4

Karel is an educational programming language for beginners, created by Richard E. Pattis in his book Karel The Robot: A Gentle Introduction to the Art of Programming. Pattis used the language in his courses at Stanford University, California. The language is named after Karel Čapek, a Czech writer who introduced the word robot.

The following is a simple example of Karel syntax:

BEGINNING-OF-PROGRAM

DEFINE turnright AS

BEGIN

turnleft;

turnleft;

turnleft

END

BEGINNING-OF-EXECUTION

ITERATE 3 TIMES

BEGIN

turnright;

move

END

turnoff

END-OF-EXECUTION

END-OF-PROGRAM

Karel++ is an OOP language, a virtual world is provided for the user in order to physically see their code application.

These robots inhabit a world lacking any sort of definite structure — it is simply a plain grid of horizontal "streets" and vertical "avenues" along which each robot can move. The map of each world is only capable of containing a set of walls and/or beepers. Beepers are items capable of manipulation granted the robot can lift these objects and place them in its beeper bag; walls are items incapable of any manipulation.

An example of a Karel++ program when robot is located on (1, 2), facing east and holding 0 beepers (This code is intended to be placed within task:

ur_Robot Karel(1, 2, East, 0);

Karel.move();

Karel.move();

Karel.pickBeeper();

Karel.move();

Karel.turnLeft();

Karel.move();

Karel.move();

Karel.putBeeper();

Karel.move();

Karel.turnOff();

Karel’s world is defined by streets running horizontally (east-west) and avenues running vertically (north-south). The intersection of a street and an avenue is called a corner. Karel can only be positioned on corners and must be facing one of the four standard compass directions (north, south, east, west). A sample Karel world is shown below. Here Karel is located at the corner of 1st Street and 1st Avenue, facing east. Several other components of Karel’s world can be seen in this example. The object in front of Karel is a beeper. As described in Rich Pattis’s book, beepers are “plastic cones which emit a quiet beeping noise.” Karel can only

...

Descargar como (para miembros actualizados)  txt (5.3 Kb)  
Leer 3 páginas más »
Disponible sólo en Clubensayos.com