Tunnel Boring Lab: A Boulder in the Way, Events
Level 10 of Tunnel Boring Lab is 12 rings of clay with a boulder somewhere in the way. Turning faster than 2 turns a minute on the stone chips the cutters. The starter turns at 3 and chips them in stroke 7. Slowing down for the whole drive works, but takes 17.8 hours. Checking the ground between rings is too late: the boulder arrives in the middle of a stroke. Students write an event handler, when a boulder is hit, turn the cutterhead at 2, which runs the moment it happens, and the drive takes 15.8 hours. Then they speed back up once the stone has passed, 14.9 hours, and compare all three programs on the same drive.
At a glance
Essential question
How can a program react to something the moment it happens?
Objectives
Students will be able to:
- explain the difference between a program that checks and one that reacts to an event
- write an event handler in Blocks and find it in Python
- explain why a check between steps can come too late
- compare three programs on the same test and choose one with numbers
- name the event, the handler and what the main program does meanwhile
Vocabulary
Event, Event handler, Polling, Torque, Boulder, Test case
Standards
3A-AP-16, HS-ETS1-4
Time and materials
45 minutes, grades 9-10.
- One computer or Chromebook per student
- A projector
- The worksheet and exit ticket, one copy each per student
- The rubric, one copy per student if you grade the work
Prep
Make copies of the worksheet and exit ticket. Before class, open mytekdev.com/try/tunnelboringlab?lesson=a-boulder-in-the-way-events&ref=tpt-tunnelboringlab-4 once on a student computer, which checks that your school's filter allows the app, and follow the short guide yourself: about ten minutes.
Assessment
- Formative: the questions under What to look for, asked while students work, and the exit ticket (answer key included).
- Summative: the worksheet, scored with the rubric.
Technology and privacy
Runs in any browser, Chromebooks included, with nothing to install. Students need no account and no email: the link works signed out, and nothing they do is stored on our server unless they choose to save.
mytekdev.com/try/tunnelboringlab?lesson=a-boulder-in-the-way-events&ref=tpt-tunnelboringlab-4mytekdev.com/tools/tunnel-boring-lab/lessons/a-boulder-in-the-way-events/startEach student gets their own copy, and the same link reopens it next time. How to set up a classLesson sequence
| Minutes | Stage | What you do | What students do |
|---|---|---|---|
| 0 to 5 | Warm-up Hook | Show the title, essential question and Today I can slides (about 1 minute). Then the warm-up: does your phone check for messages, or get told? Leave the answers on the board. | Answer the warm-up on the worksheet. |
| 5 to 13 | Direct instruction (I do) Model it | Project Level 10 and press play, then Speed up twice. The street is drawn cut open along the tunnel's line like a diagram: the buildings and the road on top, then topsoil, sand, clay and granite. The machine is under the street, boring from the launch shaft on the left. The box at the top says what the level wants and what is happening; the guidance screen is the round dial. The boulder is under the clay ahead. Watch the torque in the readings jump when the cutters touch it, and the result: chipped. Open the Python tab and read the starter: a loop of strokes, nothing that could notice the stone. It's working when: Ask what the program would need to know, and when. Write "check" and "be told" on the board as two columns. | Watch, and fill in the vocabulary on the worksheet. |
| 13 to 22 | Guided practice (We do) An event handler | Students open the link or scan the QR code. A short guide walks them through running the starter, then adding when a boulder is hit with turn the cutterhead at 2 under it. Walk the room until every student has a green result, then have them open the Python tab and find def on_boulder and tbm.on. Watch for: Students who put the turn block inside the repeat instead of under the when block. It runs every ring, not when the boulder is hit. Ask: when does this block run? | Follow the guide. Write the hours, and copy the two lines of Python that make the event. |
| 22 to 37 | Independent practice (You do) Compare programs | Students run four programs on the same drive and record the hours or what went wrong: the starter at 2 turns the whole way; an if before each stroke that turns at 2 if the ground at the face is "boulder"; the event alone; and the event with, inside the repeat, an if that turns back to 3 when the ground is not "boulder". A drive is many hours of the machine's own time. Speed up, twice, runs it at 6 times faster, 22 minutes of the drive a second, so most runs take under a minute. Play always puts the machine back in the shaft and runs the program as it is now. Walk the room with the What to look for questions. If they ask: "Which program passes in the fewest hours, and what does it do that the others do not?" The fastest Watch for: Students who conclude the event alone is best. It stays at 2 for the rest of the drive after the stone; speeding back up saves another hour. | Fill in the table with four programs, and answer the questions. |
| 37 to 45 | Closure Why was the check too late? And exit ticket | Show the closure slide. Take explanations, then give the answer: the check ran before the stroke, and the stone came in the middle. Back to the warm-up: which is the phone that is told? Hand out the exit ticket. | Explain the timing in their own words, then answer the exit ticket. |
Before you teach: a ten-minute walkthrough
Open mytekdev.com/try/tunnelboringlab?lesson=a-boulder-in-the-way-events&ref=tpt-tunnelboringlab-4. A short guide opens over Level 10, A boulder. The street is drawn cut open along the tunnel's line like a diagram: the buildings and the road on top, then topsoil, sand, clay and granite. The machine is under the street, boring from the launch shaft on the left. The box at the top says what the level wants and what is happening; the guidance screen is the round dial.
- The starter. Push 50 on every side, 3 turns a minute, a stroke and a ring 20 times; the level ends at 12 rings. The boulder is in the clay a little below the line, about 12 m from the shaft, and first touches the cutterhead partway through stroke 7.
- The rule. On the stone, more than 2 turns a minute, or more than 160 kN on each cutter, chips the cutters after 30 seconds. At a push of 50 each cutter is pressed with 135 kN in clay, so the push is safe and the turns are the problem.
- The event. Blocks: when a boulder is hit, turn the cutterhead at 2 turns a minute. Python shows it as def on_boulder(): with tbm.spin(2) inside, and tbm.on("boulder", on_boulder). It runs the moment the cutterhead touches the stone, in the middle of the stroke, then the main program carries on where it was.
- Speed. A drive is many hours of the machine's own time. Speed up, twice, runs it at 6 times faster, 22 minutes of the drive a second, so most runs take under a minute. Play always puts the machine back in the shaft and runs the program as it is now.
- Numbers to expect. The starter at 3: chipped in stroke 7. 2.5 the whole way: chipped. 2 the whole way: passes, 17.8 hours. An if before each stroke that turns at 2 if the ground at the face is "boulder": chipped. The event alone: 15.8 hours. The event, and an if in the repeat that turns back to 3 when the ground is not "boulder": 14.9 hours. The event with the push at 70: chipped, 258 kN a cutter.
Background for the teacher
Most of a program runs in order, top to bottom. An event-driven program also says what to do when something happens, and the system calls that code the moment it does, wherever the main program is. Web pages work this way (a click handler), and so do games and phones. The other way to find out is polling: check again and again at set times. Polling is simple, but it only sees what is true when it looks.
Here the main program checks between strokes, and a stroke takes about 40 minutes of the drive's time. The boulder arrives partway through one, so a check before the stroke sees clay, and the next check is far too late. The handler runs on the hit itself.
Boulders are a real hazard for soft-ground machines. Disc cutters are built to roll on rock, but a sudden hard stone in soft clay hits them with a shock. Real operators watch the torque for the same jump and slow the cutterhead and lighten the push until the stone is through.
What to look for
Ask these while students work. A student who has understood the lesson can answer them without help:
- What is the event, and what is the handler?
- Where is the main program when the handler runs?
- Why is it fair to compare your program with your partner's?
- Why did the check before each stroke not save the cutters?
- Which program would you run on a real drive, and why?
Cross-curricular extensions
- Math: how many hours does the event save over 2 the whole way, as a percent?
- Earth science: how did boulders get into clay? Look up glacial till.
- Careers: look up what an embedded software engineer does, and where events are used in machines.
- Computer science: find an event in a web page you use, such as a button click, and say what its handler does.
Vocabulary
| Event | Something that happens while a program runs, like the cutterhead hitting a boulder. |
| Event handler | The code that runs when its event happens. In Python here, a function given to tbm.on. |
| Polling | Checking for something again and again at set times, like reading the ground between rings. |
| Torque | The turning force on the cutterhead. It jumps when the cutters hit stone. |
| Boulder | A large stone left in the clay, here 3 m across, harder than the ground round it. |
| Test case | One run that checks a program, the same each time so programs can be compared. |
Differentiation
English learners
- Keep the vocabulary slide up, and point at the machine, the guidance screen or the readings as you say each word: the picture carries the meaning.
- Give a sentence frame on a card: When ____ happens, the handler ____. The check was too late because ____.
- Use a classroom example: a fire alarm (an event) against walking the halls every hour looking for smoke (polling).
Students with IEPs or 504 plans
- Pair students, one at the keyboard and one recording numbers.
- Give the four programs as pictures of the blocks on a card.
- Where the IEP allows a modified assignment, score the first two rubric rows only.
Students who need more support
- Build the event together on the board, one block at a time.
- Fill in the 2-the-whole-way row together from a class run.
- The result line after a chip says what to add.
Students ready for more
- Push 70 on every side with the event. Why does it still chip? (Read the kN in the result.)
- Write the event in Python yourself in an empty Level 10, with def and tbm.on.
- Open Level 13: the boulder is on a curve. Why does a push set once at the start stop working when the event slows the machine?
Adapting for other grades
Younger students: In grades 7 and 8, build the event together on the board, then let pairs compare it with 2 the whole way. Score the first two rubric rows, total 8, and 6 meets the objectives.
Older students: In grades 11 and 12, write all four programs in Python, then discuss what happens if an event arrives while its own handler is running, and how the app's handler returns to the main program where it left off.
Tunnel Boring Lab: A Boulder in the Way, Events
Student worksheet
Name: ______________________________ Date: ______________
Open the app: scan the QR code, or go to mytekdev.com/try/tunnelboringlab?lesson=a-boulder-in-the-way-events
Essential question: How can a program react to something the moment it happens?
Warm-up: Does your phone check for messages, or get told? Which is better, and why? ________________________
- Vocabulary. Event, event handler, polling, torque, boulder, test case: write each in your own words.
- The starter. At 3 turns a minute the cutters ____ in stroke ____ .
- My table. Program / hours or what went wrong. 2 the whole way: ____. A check before each stroke: ____. The event: ____. The event and back to 3: ____.
- The Python. The two lines that make the event: ______________________________
1. Which program would you run on a real drive, and why?
2. Why did the check before each stroke come too late?
Tunnel Boring Lab: A Boulder in the Way, Events
Exit ticket
Name: ______________________________
1. In tbm.on("boulder", on_boulder), the handler is: (A) "boulder" (B) on_boulder (C) tbm
2. Checking the ground before each stroke is an example of: (A) an event (B) polling (C) a handler
3. A friend says an event is no better than an if, since both check for the boulder. Use what you learned today to answer them.
Answer key: exit ticket
| Question | Answer | Why |
|---|---|---|
| 1 | B | The function the machine calls when the event happens. |
| 2 | B | It checks at set times and sees only what is true when it looks. |
| 3 | Open answer | The if only checks before the stroke, and the stone arrives in the middle of it, so the cutters chip. The event runs the moment the boulder is hit. |
Worksheet: what students should find
| Blank | What the app shows |
|---|---|
| The starter | Chip, in stroke 7. |
| My table | 2 the whole way: 17.8 hours. A check before each stroke: chipped. The event: 15.8 hours. The event and back to 3: 14.9 hours. |
| The Python | def on_boulder(): (with tbm.spin(2) inside) and tbm.on("boulder", on_boulder). |
| Question 1 | Open: the event and back to 3, the fewest hours with no chips, with that reason, is the best answer. |
| Question 2 | The boulder arrives in the middle of a stroke, after the check said clay, and the next check is after the stroke. |
Rubric
Score each row from 1 to 4.
Name: ______________________________
| Criteria | 4 Exceeds | 3 Meets | 2 Approaching | 1 Beginning |
|---|---|---|---|---|
| Writing the event | Writes the event in Blocks, finds it in Python, and names the event, the handler and what the main program does meanwhile. | Writes a working event handler and says when it runs. | Writes the blocks but in the wrong place, or cannot say when they run. | No event. |
| Comparing programs | Runs four or more programs on the same drive and records the hours or what went wrong each time. | Runs three and records each result. | Runs one or two, or records without numbers. | Does not compare. |
| Explaining the timing | Explains why the check between rings was too late, with when the boulder arrived. | Says the event runs the moment it happens and the check does not. | Says the event is better without why. | No explanation. |
Total: ____ / 12. A score of 9 or more meets the objectives.
Standards
The lesson is built for CSTA 3A-AP-16, programs that use events to start instructions, tested as one test case across several programs (the high school level of 2-AP-17). The simulation used to compare the programs fits HS-ETS1-4.
| Framework | Code | Grades | Standard | How the lesson meets it |
|---|---|---|---|---|
| CSTA 2017 | 3A-AP-16 | 9-10 | Design and iteratively develop computational artifacts for practical intent, personal expression, or to address a societal issue by using events to initiate instructions. | Students write an event handler that slows the cutterhead when a boulder is hit, and develop it from a failing program to one that also speeds back up. |
| NGSS | HS-ETS1-4 | 9-12 | Use a computer simulation to model the impact of proposed solutions to a complex real-world problem with numerous criteria and constraints on interactions within and between systems relevant to the problem. | The drive is the computer simulation; students compare four programs on it by hours and by whether the cutters chip. |
Checked November 2026 against: CSTA K-12 Computer Science Standards, Revised 2017, NGSS: HS-ETS1 Engineering Design.
Optional: save student work in a free class
The whole lesson runs at the link on the worksheet, with no accounts and no sign-up.
To keep students' work, and see it all in one place, make a free class. It takes about ten minutes, once, and covers every lesson in this series: mytekdev.com/tools/class-setup
Students in a class open mytekdev.com/tools/tunnel-boring-lab/lessons/a-boulder-in-the-way-events/start instead of the worksheet link. Each one gets their own copy of the starter, and the same link reopens it next time.