[Robot]
  Reeborg the Robot  

Programs



Reeborg's Basic Vocabulary

Reeborg has five built-in, or primitive, instructions. (By primitive, we mean they are elementary and basic.) Reeborg executes an instruction by performing the the action associated with that instruction. The five primitive instructions are:
move()
Reeborg moves forward one block. He continues to face the same direction. To avoid damage Reeborg will not move forward when his path is blocked by a wall. Instead, Reeborg performs an error shutoff.
turn_left()
Reeborg turns by pivoting 90 degrees to the left. He remains on the same street corner.
pick_beeper()
Reeborg picks up exactly one beeper from the corner on which he is standing and puts it in his (soundproof) pocket. If there is no beeper, Reeborg performs an error shutoff
put_beeper()
Reeborg extracts a beeper from his pocket and places it on the current street corner. If his pocket is empty, Reeborg performs an error shutoff.
turn_off()
Reeborg turns himself off and is incapable of executing any more instructions. This must be the last instruction executed in every robot program.

An Example Robot Program

To illustrate how these commands are packaged together to form a program for Reeborg to execute, examine the two situations below. The initial situation, on the left, shows Reeborg on street 2 avenue 2 facing East. At street 2 avenue 4 there is a beeper that we want Reeborg to transport to street 4 avenue 5. The final situation, on the right, shows the beeper moved to street 4 avenue 5. Reeborg has turned himself off one block further North at street 5 avenue 5 facing North. The following robot program correctly instructs Reeborg to perform this task.



# Beeper transport program. 

move();
move();
pick_beeper();
move();
turn_left();
move();
move();
put_beeper();
move();
turn_off();

Lines that start with # are comments to be read by humans.

Programming Errors






Start of task

End of task

Erroneous Program

    move()
    pick_beeber()
    turn_left().
    put_beeper()
    move
   When you first write a robot program, chances are that it will contain some errors. There are four types of programming errors:
Lexical Errors
The program contains an instruction or keyword that Reeborg does not know. These are akin to spelling errors in English.
Syntactic Errors
The rules for robot programming are violated, for example a missing semicolon or a keyword at the wrong place. These are akin to errors in grammar in English.
Execution Errors
Reeborg performs an error shutoff. This could happen because
  • he runs into a wall
  • a pick_beeper() command is executed on a beeper-less corner
  • a put_beeper() command is executed with an empty pocket
Intent (or Logic) Errors
Reeborg performs a task which is different from his assigned task.
Prior to running a program, it must be analyzed either by a compiler, a program that translates the programs as written by us human programmers (we call this form the source code) into the machine code form that the computer can execute (we call this form the executable code) or by an interpreter that translates the programs into some internal form that is then directly executed by the interpreter. (Python is typically used with an interpreter.) This analysis phase, whether performed by a compiler or an interpreter, we call compile-time.

Lexical and Syntactic errors are detected during the translation phase; hence we often call these first two types of errors compile-time errors.

Execution and Intent (Logic) errors occur when the program is running; hence we often call these last two types of errors run-time errors.


  ⇐ This program on the left contains all of these four errors. Can you find and identify them? (The errors.)






Prior Topic       |       Next Topic  

[MTSU]  | CS  | [Home] Return to Reeborg home page
(Credits and Copyrights)