Acting Out Algorithms

Computational Thinking, Creativity, Education, MSU MAET, Museums

Programming can be intimidating, but by allowing students and museum visitors to take on roles of characters engaged in computational thinking, they can gain an understanding of how an algorithm works in a visceral way. Visitors can not only view but also participate in a stage show where they can work alongside museum staff to act out a basic understanding of computer programs. During the play, characters will use motions to reinforce what each part of the algorithm does, further embodying the concept being learned.

Programmers solve problems. They accomplish this by working with or taking inspiration from computers to find solutions to problems, but they don’t do it alone. They have a set of thinking tools that will allow them to accomplish their tasks more easily called computational thinking. The play will explore different computational thinking skills as well as basic tools available to programmers. Even the play itself is an example of computational thinking, as actors are using a simulation to gain a better understanding of algorithms, just as a computer may be used to run a simulation to better understand a problem.

During the play, depth sensing cameras such as Microsoft Kinects cameras will track the motion of the actors, and display them on a screen with appropriate attire (a witches gown, a suit of armor) overlayed on the actors body. As the protagonist solves problems, he or she will make motions to represent different parts of algorithms, such as variables, functions, if/then statements and loops. The cameras can display this motion as shapes created by the actor’s hands. A proof of concept can be seen here:

To begin the tale, we need a problem that should be solved. Ask the audience: what’s a common problem found in fairy tales? If the knight saving the princess is offered up, say that you would like to show that everyone has problem solving skills, many of which are not best solved by brute force, so in this case it will be the princess saving the knight from the wizard. Using fairy tales as a common trope to frame the play was inspired by Computational Fairy Tales.

Variables / Abstraction

NARRATOR: An evil wizard had kidnapped the bravest knight in the realm, and it was up to the princess to rescue the knight. Before the princess could even think about approaching the evil wizard, she needed to figure out how to defeat him. She decided to visit a local witch who had gone to school with the evil wizard long ago.

WITCH: Come in, my dear! Enjoy some lovely frog wart tea. How may I help you?

PRINCESS: I’m off to save a knight of my kingdom being held by the evil wizard, but need to know if the wizard has any weaknesses that might allow me to defeat him/her.

WITCH: Ah yes, I remember the wizard well. When I knew him, he had green hair, black fingernails, a long nose…

PRINCESS: Wait, wait! I don’t need to know everything about him. In fact, all I need to know is information useful for my problem.

WITCH: Ah! So you are looking for an abstraction of the wizard, or a simplified way of thinking about the wizard that only focuses on how to defeat him/her. Well, there are three things you should know: The wizard loves chocolate, has four magic wands that could be used to cast a curse on you, and can be weakened by saying the magic word “zzyglic”. Will you remember all that?

PRINCESS: Hmm, I still have a long way to go before reaching the wizards lair. Do you have any way I could save that information?

WITCH: I happen to have three variables here that you can use to hold that information. [She takes out three pouches, labeled “likesChocolate”, “numWands” and “magicWord”.] You can store each bit of data in these variables. As the name variable suggests, if you ever need to change any of these values, you can just change what these variable pouches contain. In fact, to bring these variables up again, just start a spell by moving as if you are putting something in a pouch. Your variables will show up on your belt and you can access them again.

PRINCESS: [Acts out putting something in a pouch] Thanks! Now I can store this information for use later. See you!

[On the screen behind the play, part of the Python program is displayed:
likesChocolate = True
numWands = 4
magicWord = “zzyglic” ]

Functions / Problem Decomposition and Patterning

NARRATOR: After leaving the witch’s hut, the princess began walking towards Mt. Error knowing that she had a long journey ahead of her. As she started out, she crossed paths with a hermit.

HERMIT: And where are you off to, young one?

PRINCESS: I’m headed to confront the wizard, but there’s so much I have to do in order to even reach his lair. I’m feeling a bit overwhelmed.

HERMIT: Well, any time I’m facing a particularly large problem, I like to use problem decomposition to make it more manageable. All you need to do is break the large problem into several smaller problems that you could tackle individually and more easily. Now, what do you have to do to defeat the wizard?

PRINCESS: First I have to cross the hills, the jungle, and the desert, then find a way past the wizard’s booby traps, and finally defeat the wizard himself.

HERMIT: Ah, if you tackle each smaller problem separately, it doesn’t sound nearly as bad. I even notice a pattern in what you have to do. Would crossing the hills, jungle, and desert happen in a similar way?

PRINCESS: Certainly, all I have to do is keep the morning sun to my right, find food and water on the way, and seek shelter every night.

HERMIT: We can use that pattern to create a spell for crossing any type of land. We will put the general instructions for crossing into the spell which we will call a function, which we could use anytime we have to cross any type of land. The functions will make it much simpler to give instructions on how to reach the mountain. To make these functions, you need to make the motion of something big turning into something small – to show breaking up the problem.

PRINCESS: Ok, I’ll try that spell. Going from a big set of instructions to something smaller and more manageable.  I can feel it working!

[On screen, add calls to cross(hills) , cross(jungle) , cross(desert)]

Thanks! This makes it seem much easier. I’m off!

If/Else Statements / Conditional Logic

NARRATOR: Through the use of her functions, the princess made fast work of reaching the base of Mt. Error. There she found pillars of fire blocking the pathin order to reach the wizard’s lair.

PRINCESS: Wow, this looks impossible. There’s no way I can get past these traps safely.

RAVEN [flying up]: Hullo! You seem lost. Have you been here long?

PRINCESS: I’ve been looking for any patterns that will allow me to go past the pillars of fire, but it’s hard to break it down in a way that’s easy to remember.

RAVEN: Ah, I have just the ticket! I happen to be an expert in making decisions using conditional logic. Have you ever used such things before?

PRINCESS: No, I don’t believe so.

RAVEN: I think you have without even realizing it. For instance, what time do you wake up in the morning?

PRINCESS: Well, it depends. If I have lessons that day, then I get up before the sun rises. Else I get up an hour after sunrise.

RAVEN: Then you do know how to use conditional logic! We could easily follow your decision by writing:

if today.isSchoolDay():
 getUp(7:00 AM)
 getUp(9:00 AM)

Now all we have to do is find a way to use this for the pillars of fire. I’ve watched them for many days and have noticed that there is a light at the entrance of the wizard’s lair that glows red when there are no flames on the left side of the path and blue when the right side will be clear. How could we make a statement to describe how you should move?

PRINCESS: Well, it would be pretty easy. I could just say

if light == red:

RAVEN: That’s it! As long as you follow that conditional logic, you should have no problem getting up the path safely. To start the spell, shrug to check if your statement is true, and then point with the hand for the direction you want to go. Good luck!

[The princess watches the light, gestures the spell, and follows the if/else statement to reach the wizard’s lair]

Loops / Algorithms

NARRATOR: Upon reaching the lair when the knight was being kept by the evil wizard, the princess had to decide how to distract the wizard so she could free the knight.

PRINCESS: The wizard looks like he’s guarding the knight closely. I could use my conditional logic thinking to figure this out. If likesChocolate is True, then I can use my candy stash to distract him. [She places some chocolate on a table.]

WIZARD: Ahah! I didn’t realize I had some treats left. I hope you don’t mind, Sir Knight, but I am going to indulge in one of my weakness: chocolate!

PRINCESS: [whispered] Sir Knight! I am here to rescue you. Have you seen the wizard’s wands?

KNIGHT: Indeed, knave, he keeps them on his wand wall, but I think you will find that they are most hard to break due to their magical nature.

PRINCESS: Luckily, I have saved the magic word as a variable, see?  magicWord = “zzyglic” All I will have to do is say it for each wand, and I know that numWands = 4. Here I go: zzyglic, zzyglac, ssyglab, ack! This is so hard to say over and over again.

KNIGHT: Might I suggest using a loop? There happens to be a for loop right over there. The loop provides a shortcut so you can use it to only have to say the magic word once, and the loop will repeat for however many times you desire. For instance, you could simply say:

for wand in cabinet:
 print magicWord +’ to break the ’ + wand

To start the loop spell, make a circular motion with your hand and it should begin.

PRINCESS: Terrific! I will make the loop motion. Here we go… wait. It looks like the wands are splintering, but it will take many times to say the magic word. I don’t even know how many times I will have to say it!

KNIGHT: I just so happen to have another type of loop hidden in my armor. It’s called a while loop. You can have your instructions repeated over and over while some condition is true. We can take your for loop and place it in a while loop so that the magic word will continue to be said for each wand until they are broken:

while magicPower == True:
 for wand in cabinet:
   print magicWord +’ to break the ’ + wand

PRINCESS: Ok, I’ll make another loop spell with my gesture.That did the trick! I see the wands are continuing to break down each time we go through the while loop, and.. yes, they’ve broken, and the while loop stops since the magicPower is no longer True!

WIZARD: What have you done! I can do nothing to stop the knight from breaking out of his magical bonds! I’m melting, melting! No wait, I’m fine, I just can’t use my magic any more.

KNIGHT: I’m free! Thank you, fair princess! You did it!

PRINCESS: All the new computational thinking skills I learned along the way made it possible! Now I can use them in many different ways and can do even more with the help of computers. Thanks to all who helped our quest be successful!

NARRATOR: And everyone lived happily ever after, even the wizard, who started a new online chocolate delivery system. Good night all!


Leave a Reply

Your email address will not be published. Required fields are marked *