Debugging Shakey Programs

Section: Robots, Real and Imagined
...Subsection: Debugging Shakey Programs

Thank you, Lieutenant Woof.
It is WORF, madam!
Star Trek, The Next Generation

There are two type of errors, or bugs, that can creep into your program. A syntactic error occurs when Shakey sees a word in his program that is not part of his vocabulary. If you inadvertently enter loft instead of left, then the computer will not even attempt to execute your program. Instead you are presented with an error message giving the nature and location of the bug.

Happily, the programming environment you will use insulates you from such tedious syntactic bugs, since you do not actually type your program yourself. The program construction is carried out automatically. All you need to do is select the appropriate program elements in the appropriate order. Thus, you need not worry about typos or forgetting punctuation. You can concentrate on the more important task of program and correctness.

Assuming your program does not contain any syntactic errors (and it won't if you construct it inside the programming environment), then the computer will execute the program. Semantic errors are mistakes in the logic of the program, and emerge when the program is run. For example, it is a semantic error if you direct Shakey to step into a wall at some point.

Just because Shakey successfully completes his program without any error messages, does not mean that the program is error free. Perhaps he does not successfully complete his task. Only you can judge whether or not the result of running the program is correct. For example, suppose you want Shakey to jump three hurdles, but when your program runs, he only jumps over two hurdles. In that case, you must go back and re-examine your logic, make corrections, and run the program again. This is analogous to tasting your cherry pie to see if it turned out well. If it didn't, you must analyze your recipe to determine what caused the failure.

Rarely is a program bug free on the first draft. Debugging is the main activity of even expert programmers.


Suzanne Menzel; menzel@cs.indiana.edu