Karel

Páginas: 4 (792 palabras) Publicado: 10 de octubre de 2012
Resources of Karel the Robot
A. The Bag
For each new task or problem that Karel will solve, we have to define and to configure how it will begin its world, this is, where there will be walls andwhere there will be beepers, besides if the new task requires it, also we can place beepers in the bag, as part of the initial conditions of the world of the robot.
During the execution of theprogram, each time it is indicated to the Robot to pick up a beeper, Karel place it in its bag of beepers, besides in all time, you can order to Karel the Robot that leaves a beeper of the ones it has inits bag, in the corner where it is placed.
B. The sensors
The Robot has different kind of sensors; these sensors permit to take into account the following:
• If there is or not a wall in front ofwhere it is standing
• If there is or not a wall to its left where it is standing
• If there is or not a wall to the right where it is standing
• If there is or not a beeper in the corner where itis standing
• If it has or not, at least, one beeper in its bag of beepers
• To know in what direction is looking

Thanks to the sensors that Karel has, ir is possible to detect the followingconditions, that we can use inside a conditional statement “if (condition)”, or inside a statement of repetition “while (condition)”; this means that we can order to Karel that asks its sensors ifsome of the following conditions “is fulfilled”, and the corresponding sensor will answer with “false” or with “true”:

frontIsClear ()
nextToABeeper ()
facingEast ()
frontIsBlocked ()notNextToABeeper ()
facingWest ()
leftIsClear ()
anyBeepersInBeeperBag ()
notFacingNorth ()
leftIsBlocked ()
Is it clear in front?
Am I next to a beeper?
Am I in the East direction?
Is it blocked infront?
Am I not next to a beeper?
Am I in the West direction?
Is it clear to my left?
Are there beepers in my bag of beepers?
Am I not in the North direction?
Is it blocked to my left?...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Karel
  • karel
  • Karel
  • karel
  • karel
  • Karel
  • karel
  • karel

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS