Programs can be constructed for Karel that will allow him to find a beeper by navigating through a maze. This sample program has Karel follow walls looking for openings until he locates a beeper. You can find this program in the distribution in file `samples/maze.k'.
{ karel follows the right wall until a beeper is found} BEGINNING-OF-PROGRAM DEFINE-NEW-INSTRUCTION turnright AS ITERATE 3 TIMES turnleft; BEGINNING-OF-EXECUTION WHILE not-next-to-a-beeper DO BEGIN IF right-is-clear THEN turnright ELSE WHILE front-is-blocked DO turnleft; move END; turnoff END-OF-EXECUTION END-OF-PROGRAM
Go to the first, previous, next, last section, table of contents.