Lesson planBranching Paths: Code a Choose-Your-Path Adventure With Variables
STEAM55 minutesGrades: 11th
Overview
Plan a branching story on paper, then code it in Twine with a variable.
Description
Your teen maps a short choose-your-path story of 8 to 12 passages as a sticky-note flowchart, then builds it in Twine, a free browser tool for interactive stories. They add one variable, such as $keys or $health, that changes which of at least three endings a player can reach, and a family member playtests every branch while your teen fixes dead ends and pacing problems.
Objective
Your teen will sequence events in a branching narrative so each path builds toward a clear tone and outcome, and will use a state variable and a conditional to control which endings unlock.
Standards
Use a variety of techniques to sequence events so that they build on one another to create a coherent whole and build toward a particular tone and outcome (e.g., a sense of mystery, suspense, growth, or resolution).
Materials
| Item | Quantity |
|---|
| Sticky notes | about 15 |
| Large sheet of poster paper or 2 taped sheets of printer paper | 1 |
| Markers (two colors) | 2 |
| Computer with a web browser (Twine runs free at twinery.org with no download) | 1 |
| Index cards for playtest notes | 3 |
Vocabulary
Branch
A point in an interactive story where the player's choice sends the story down a different path.
State variable
A value the game remembers between passages, such as $keys = 2, that can change and affect what happens later.
Conditional
An if/else rule that checks a variable and shows different text or links depending on its value.
Dead end
A passage with no way forward and no ending, usually caused by a missing link or a mistyped passage name.
Bottleneck
A passage that several branches lead back into, which keeps a branching story from growing out of control.
Preparation
- Open twinery.org in a browser and click 'Use it online' so the editor is ready; stories save in that browser, so use the same computer each time.
- Clear a wall, door or table where the poster paper can lie flat for the flowchart.
- Ask one family member to be ready for a 10-minute playtest near the end.
Introduction
Ask your teen: in a game with choices, have you ever felt a choice mattered, and another time felt it was fake? Tell them today they will build a story where one remembered detail, like whether you picked up a key, really changes the ending.
What makes a choice in a story feel meaningful instead of cosmetic?
If a story has three choices at every step, how many paths are there after four steps, and why do writers use bottlenecks?
Steps
1Step 1
Plan the tone and the variable
(7 min) Your teen decides the outcome tone they want (mystery, suspense or growth), a one-sentence premise and one variable the player will collect or lose, such as keys, health or trust. They write the premise and the variable's starting value at the top of the poster paper with the first marker.
2Step 2
Flowchart the passages
(12 min) Your teen writes one passage idea per sticky note, using about 10 of the sticky notes, and arranges them on the poster paper with arrows in the second marker color for every choice. They mark where the variable changes with a plus or minus sign and plan at least one bottleneck and three endings, one of which only unlocks if the variable reaches a set value.
3Step 3
Build it in Twine
(18 min) On the computer your teen creates a new Twine story and types each sticky-note passage, linking choices with double square brackets. They set the variable in the first passage with a line like (set: $keys to 0), change it on the right passages, and add a conditional before the locked ending, such as (if: $keys >= 2)[[[Open the vault]]](else:)[The door will not budge.].
4Step 4
Playtest every branch
(10 min) A family member plays the story while your teen watches silently, then plays again until every path has been tried. On the 3 index cards your teen notes each dead end, any ending that felt unearned and the moment the tension was highest.
5Step 5
Fix and tighten the sequence
(8 min) Your teen repairs dead ends, reorders or rewrites at least one passage so the events build toward the planned tone, and replays the locked ending to confirm the variable works. They finish by writing two sentences on an index card explaining how one branch builds suspense step by step.
Conclusion
Have your teen play the story's best ending for you and explain which earlier passage made it feel earned. Branching stories work like any good story: each event has to build on the last one, even when the reader picks the path.
Make your own lesson plan in minutes
Describe a topic and Resource Portal AI writes the objectives, materials and steps for your group.
Try Resource Portal AI