Introduction to Computer Science
CompSci 101 : Spring 2014

Making Peanut Butter and Jelly

Forget what you have seen in the movies about robots taking over the world while acting (and looking) like people, we are still very long far away from that sort of technology. Google has been able to create cars that drive autonomously because there is a lot of empty space inside of big cars, there are not many actions a car can take, and, believe it or not, a road is a farily simple and constrained environment to operate in. Thus, for Google, the biggest challenge was processing the information quickly enough to be able to make the right choices. The embedded video shows just how hard it is to make a robot that does something humans take for granted, even when you constrain the location of the ingredients to a degree that makes the system impractical.

These difficulties arise because computers have no common sense with which to interpret instructions the way you really intended them to be carried out and no flexibility to react to unknown situtations. It is one-hundred percent literal minded and only "knows" what it has been "taught" by its human programmers. Here is an example of how far someone has gone to try to simulate a "robot experience".


Describe an algorithm that someone could follow to make a peanut butter and jelly sandwich. When listing the steps in your algorithm, assume the person following your instructions is as "dumb" as a computer.

All modern programming languages provide the computer with some basic "knowledge", stuff it knows when it starts. For example, most programming languages allow you to enter algebraic expressions in the common infix format you have used since elementary school. In other words, the computer knows how to do algebra. It is convenient to have some commands built in so that you do not have to build everything from scratch. To simulate this knowledge, there are certain things you can assume our sandwich making computer knows how to:

Our sandwich making computer has the following things already available on the counter to work with: