BEGINNING-OF-PROGRAM

  DEFINE-NEW-INSTRUCTION turnright AS
  BEGIN
    turnleft;
    turnleft;
    turnleft
  END;


  BEGINNING-OF-EXECUTION

    while right-is-blocked do
    begin

      if front-is-clear then
        move;

      if right-is-clear then
      begin
        if left-is-blocked then
        begin
          turnright;
          move
        end
      end
      else if left-is-clear then
        turnleft

    end;

    turnoff

  END-OF-EXECUTION

END-OF-PROGRAM