Teaching kids Lua programming with ComputerCraft
My 8 year old son Isaac, like many children his age, is a huge fan of the computer game Minecraft. Minecraft is a game of exploration and construction where every object in a randomly generated world is represented as a block. There are no explicit goals in the game, and the player has the freedom to decide how they are going to play and what they will build.
ComputerCraft and Lua
In the five years since it’s alpha release, Minecraft has grown a thriving developer community. Hundreds of third party modifications are available which significantly expand the capabilities of the vanilla game. ComputerCraft, an addon by Daniel Ratcliffe (@DanTwoHundred), adds computers, peripherals and turtles to Minecraft, which are programmed in the Lua programming language.
The ComputerCraft Institute
Several weeks ago I began developing an in-game learning resource for primary school children that I’ve called The ComputerCraft Institute. The goal of the ComputerCraft Institute is to build a series of lessons within Minecraft that guide kids through the fundamentals of programming and using a text-based command shell. Each room within the ComputerCraft Institute contains a simple exercise designed to teach a particular concept.
Ideally children will have an instructor working through the exercises with them in-game, but there are instructions posted on monitors throughout the institute.
Since the 1970s, the Logo programming language has been used in education to teach programming fundamentals.
ComputerCraft turtles are similar to Logo turtles and can be programmed to move about in 3d space with functions such as:
turtle.forward() turtle.back() turtle.turnRight() turtle.turnLeft()
Turtles are an ideal way to teach many programming concepts and are great for kids as they provide very tangible feedback. The exercise below teaches children basic imperative programming by having them guide a turtle through a simple maze. By the end of the exercise the kids understand how to use the CraftOS text editor, and both write and run a simple program.
Later exercises introduce the concept of loops, moving turtles in 3D space, digging, collecting resources and interacting with the world.
The ComputerCraft Institute world is an ongoing project and is available from Github. The first version of the ComputerCraft Institute required some additional mods available via the Feed the Beast modpack, but for the sake of simplicity, future versions will only have vanilla Minecraft and ComputerCraft as dependencies.
The following YouTube video is a narrated walkthrough of an earlier version of the ComputerCraft Institute:
I’d like to thank Blair McBride (@theunfocused) of Mozilla and Tim Penhey (@howbazaar) of Canonical, two local Dunedin developers, for contributing Minecraft licenses to help run this workshop. Thanks also to Simon Clarke, Sue Graham and the children of room 3 at Kaikorai Primary. I had a great time teaching this workshop and was very impressed with the children’s enthusiasm and aptitude. I look forward to developing more resources and running more workshops in the future!
blog comments powered by Disqus