Peanut Butter and Jelly Ending Peanut Butter and Jelly Ending

I have a task that I started with a group of 4th-6th graders at the beginning of a short course on Artificial Intelligence.  In order to demonstrate how exact computers are about their instructions, I've created a strict syntax for a fictional robot and a series of environmental specifications.  The students must use the syntax provided (in something resembling an API) to generate commands that the Robot will ultimately use to create a Peanut Butter and Jelly Sandwich.*

I've also created a little engine that can run this all at the command prompt, and gives back useful errors if the students either generate a syntax error (ie. take rightHand plate instead of take plate rightHand) or attempts an illegal action (such as take plate rightHand when rightHand is already full).  I have not yet given them access to the engine; they spent the last 15 minutes of the previous period trying to generate a full set of working instructions from the specification, and they had a lot of fun doing it!

I have a vague notion about what will come next; I want to integrate allowing them to copy/paste their instructions into the engine to see if they have run into trouble, and creating an actual PB&amp;J sandwich (or whatever components of that sandwich they've actually managed to make.)  I have already checked about allergies to peanuts, so we should be safe there.

What I don't quite see is how to integrate those two activities so that it won't get bogged down.  If I enact the PB&amp;J creation faithfully, I won't be able to do it for every child.  If I ask them to create it, they might just change their commands as soon as they see an error, which would let everyone get a sandwich, but wouldn't be as fun.

The lesson has had a great start.  How can I finish it up to make it into a home run?

* - I know that folks in some countries don't eat Peanut Butter and Jelly sandwiches. That's fine as far as it goes, but please know that you are wrong.**

** - Unless of course you are allergic to peanuts.
I think the "peanut butter jelly sandwich challenge" is a great lesson in general, but it's especially great for computer science. Kudos.

That being said, I think you might be conflating two separate topics that are each worth their own lessons:


The exactness of syntax: take rightHand plate and take plate rightHand are two different things, and a computer might not be able to understand what you mean.
The exactness of semantics: take plate rightHand might sound like an obvious instruction to a human, but that's because we've had years of practice picking up plates with our hands. But a computer hasn't had that practice! What if it tries to pick up the plate with a fist? What if it tries to grab a plate by the middle instead of by the edge? So often our instructions to a computer have to be much more detailed than we first thought.


The "semantic exactness" part is the real beauty of the peanut butter jelly sandwich challenge, imho. One of the hardest things to do in computer science is take things that humans "just do" and break them down into individual steps. If they continue exploring CS, your students will eventually have to ask questions like "how would I sort a stack of index cards with numbers written on them?", and their initial reaction will be "I don't know, I just do it!". The peanut butter jelly sandwich challenge teaches them to dig a little deeper than that first reaction, and to start breaking things down into smaller steps.

And the fun part is that no matter how exact students make their instructions, you can always find a way to get it wrong.

Anyway, back to your actual question: I would propose a three-part lesson:


Step one: Have students come up with "programs" that they enter into your engine. This might be a homework assignment. This teaches them the "syntactic exactness" part, and gets them thinking about breaking things down into smaller steps.
Step two: In class, have students volunteer to read off their programs. You follow their instructions, pointing out as many inconsistensies as you want, in as messy a way as you want. After a few examples, take a step back and give them the lesson that even if your syntax is valid, sometimes your semantics can be unclear. Then maybe have them abandon your syntax and give you instructions in English, that way they can be more specific about each step. But like I said before, no matter how exact their instructions are, you can still find a way to get it wrong.
Step three: After a few rounds of this, have students break off into pairs: one student giving instructions, one following them and getting it wrong in the same way you did. Whether you give them real ingredients or tell them to pretend they have real ingredients is up to you and how much of a mess you want to clean up afterwards.