(Unlike most of the work described on this blog, the work described in this post is mostly my own; Leo only participated as a willing player of the resulting game, and in a tiny bit of programming at the end.)
I’ve been trying for some time to get Leo to understand Turing Machines. I had high hopes for MineCraft Turing Machines that Leo found utterly fascinating … as did I! (There are some amazing videos of MineCraft Turing Machines out on YouTube!) And we’ve had a couple of iPad apps that are slightly helpful, but they aren’t really engaging enough for a seven year old. I had the idea of creating a Turing Machine mystery game, where you have to figure out what the program is doing, and I finally got around to programming it.
Because we’ve mostly been doing our collaborative programming in HopScotch, which Leo really like, I figured I’d try to make the game I’d imagined there. Unfortunately, There are many issues — such as timing problems, lack of local variables, and non-independence of cloned objects — that made HopScotch is a little too simple to make anything very complex. (Although some HopScotchers have done amazing things! Sort of like the MineCrafters building computers (and Turing Machines!) out of RedStone!) However, with a tiny bit of clever design, and a great deal of trial-and-error mucking about, I finally managed to get a simple version of the game I’d envisioned to work, and Leo actually liked it and played it!
Here are a couple of screencaps from the game in progress. By tapping on the circles, you toggle them center/up/down, and then you can start the machine, which pushes the robot on the left one cell to the right, which starts it executing The Rule. The lower picture, below, shows the state after the machine has stopped from some starting point that I don’t remember.
And here’s the rule, which is coded inside the custom function: “Execute the Rule”(Y Nil means that the circles are centered — poor choice of names!):
Leo got the idea of the game right away, and actually mostly figured out the rule by the intended game play. Then we tried to modify the rule, and although he knew what he wanted to do, which means that he got the concept (Success!), actually making the right changes to the rule case took a little collaborative programming. (My poorly chosen names, like Nil, didn’t help things!)