Using Video Games to Teach Coding: How Binary Dungeon Makes “Data Structures” Fun
Randy O’Connor, Lead Game Designer at Endless’ Terminal Two Studios, shares how thoughtful game design choices can increase learning in video games.
Games and play are a fundamental part of the human experience. We instinctively love being immersed in exciting and visually thrilling games, valuing the freedom they give to explore new things, make low-stakes choices, and take risks. A game is a place to test assumptions, compete, and grow, without the same pressures (or potential consequences) we experience elsewhere in life.
Here at Terminal Two, we partner with real game studios to turn stale coding education into gaming adventures. Terminal Two video games have the look and feel of games that kids are already playing while also teaching a wide variety of concepts at multiple skill levels. We carry students from knowing nothing about code to reading and writing it with confidence – all while having a lot of fun.
But how, as game designers, do we combine teaching real concepts with the fun of battling dangerous monsters? Read on to explore the detailed choices we made to make Binary Dungeon the most fun it could be while engaging kids in real, hands-on coding structures.
A Quick Introduction to Game Design
“Game design” is a creative practice where people (like myself) decide the rules and components of games. Historically, games began and evolved naturally through play. Over time, people would formalize their play - adding rules, removing them, adding goals and balls and tokens and grids - and popular changes got passed down to other players.
Game design is how rules, players, and components interact to create “dynamics.”
Consider the 3-point line in basketball: Simply moving that line closer or farther from the basket would significantly change the game!
If you moved the 3-point line two feet closer to the basket, players would go for 3-pointers far more often. Opposing players would think less about defending close to the basket because the 3-point was more likely, and then aggression might shift. Now the middle of the court could matter more. Training, strategy, and decision-making would all have to adjust.
If you moved the 3-point line farther away from the basket, then only Steph Curry would probably go for shots, and the 3-pointer wouldn’t matter in most games.
The choices we are given, and the results of our decisions, teach us how to act in the future.
Making “Data Structures” Fun
Now that you know a little about game design, let’s look at the central “game mechanic” in our game, Binary Dungeon, one of the many games we’ve created to teach programming concepts here at Terminal Two.
Note: This game is conceptually one of our more advanced titles.
Inspired by Classics
Binary Dungeon is inspired by The Legend of Zelda, a popular action-adventure where players explore a fantasy world on a mission to defeat the evil Ganon. In that popular Nintendo game, players must descend into mysterious and dangerous labyrinths, exploring, solving puzzles and defeating monsters.
Our game also contains labyrinths and monsters, but by changing a few rules and components, we teach players about data structures.
Background
What are data structures? A major purpose of computers is to store, display, and manipulate data. One way programmers arrange information is by storing data in a data structure called a “binary tree.”
A binary tree is a network of “nodes,” each of which contains data or information. This kind of data family tree can go on forever!
Binary trees are helpful because they can be quickly searched with the right equation. Data structures may contain millions of pieces of information, so a good search algorithm is key for interacting with the information.
Making Data Structures Fun
To teach kids about binary trees, we developed an exciting adventure where players explore a dungeon, room by room, and fight monsters. We made some specific choices that help scaffold the learning throughout the lesson:
The map functions as a data structure: Our video game world is made of rooms with entrances and exits. To make our dungeon into a binary tree, we simply constrained the rules so that all rooms must have an upper entrance, and each room can have a left and/or right exit, which will enter the top of the next room down. Now we’ve got a binary tree dungeon.
The player builds the map: Rather than just letting the player navigate the dungeon, we begin each level with a magical map, where players get to arrange the rooms themselves, however they want! We made a few key distinctions:
Players can place rooms in any order and arrangement, building a long straight path, a set of random branchings, or a nicely balanced tree.
Each level contains more rooms than the last, meaning the dungeon gets more complicated to build and explore as the player gets further in the game.
At the start of the game, the rooms have no numbers, but a few levels in, each room node is labeled with a number. A player might think about how to arrange these numbers in the tree.
Game components encourage building solid data structures: In Zelda, much of your learning involves getting better at fighting monsters. But in Binary Dungeon, you will fail if you don’t know how to optimize a binary tree! A handful of game rules and components make this work.
The goal in each level is to find a magical torch. The torch fades a little every time the player moves to a new room. This means the player has limited time to find it.
We only reveal the torch’s room number once the player exits the map screen, so players must design their map before knowing which room is the important one.
And once the map is built (but before the goal is revealed) the map is hidden and the player never gets to see it again!
The player becomes the search algorithm, moving among the nodes to find any piece of data.
As a player gets deeper into the game, they will need to learn these concepts to be efficient and succeed. A player will never wander when they’ve built a correct tree, they will just look at the room number they’re in, and the room number they need to reach, and they’ll know whether they need to go left or right.
(Or they’ll snap a photo of the map with their phone before the level begins… a different sort of optimization!)
The Final Level (Wrapping Up)
I hope this blog has provided some insight into how we make specific game design choices to build games that teach crucial lessons about data storage, coding, and beyond. Games can be a powerful way to introduce ideas through challenging players and encouraging failure in a space safe for it.
We use these principles of game design throughout our titles, and at Terminal Two, we really believe in the power of play for education. We have a passion for exploring choice and interesting systems, enabling learning for all kids across fields like computer science and programming.
Terminal Two is a company incubated by Endless that offers action-packed, self-paced games and distance-learning curriculum used by parents and teachers around the world.