Lesson 16 · Integration

Survive the Day: Your First Real Game (Where Every Choice Matters)

What You'll Learn

How to combine every skill you've learned — variables, lists, dictionaries, functions, loops, conditionals — into one complex, interactive game where your choices shape the story.

Everything Comes Together

Over the past 15 lessons, you've built up an incredible set of tools. Variables, lists, dictionaries, functions, loops, conditionals, randomness, data analysis. Each one is powerful alone.

But the real magic happens when you combine them all.

Today, you're going to build the most ambitious project of the course: a Survive Middle School Simulator. It's a game where you navigate a school day making decisions — and every choice affects your stats, your relationships, and your ending.

This lesson is different from the others. Instead of learning new concepts one at a time, we're going to design and build a complete game, and I'll show you how every skill you've learned plays a role.

Step 1: Decompose the Game (Lesson 1)

Every big project starts with decomposition — breaking it into parts. What does our game need?

Game Components

Player stats — energy, reputation, grades, friendship (Lesson 2: Abstraction — what matters?)

Scenes — morning, hallway, class, lunch, after school (Lesson 4: Categorization)

Choices — each scene offers 2-3 options (Lesson 3: Deductive Reasoning — rules for consequences)

Consequences — choices change stats (Lesson 10: Systems Thinking — pipelines)

Random events — surprise moments (Lesson 7: Inductive Reasoning)

Endings — different outcomes based on final stats (Lesson 9: Generalization)

Let's build each piece, then connect them.

Step 2: The Player (Abstraction + Data Modeling)

A real student has thousands of attributes. We need to abstract — pick only what matters for our game:

Python · Player Setup

Dictionary for the player data (Lesson 12). Function to create the player (Lesson 8). Function to display stats with visual bars (Lessons 2 and 5). Everything we've learned is here.

Step 3: The Choice Engine (Functions + Conditionals)

The core of our game: present a situation, let the player choose, and apply consequences. Let's build a general-purpose choice function:

Python · Choice Engine

The Design

Each option is a dictionary with three keys: what it says, what it does to your stats, and a flavor message.

max(0, min(10, player[stat])) keeps stats between 0 and 10. min(10, x) caps at 10. max(0, x) floors at 0.

This is the generalization principle (Lesson 9): one function handles ANY choice, with ANY number of options, affecting ANY stats. We just change the data.

Step 4: Building the Scenes

Now let's build the actual scenes of our school day. Each scene is a function that presents a situation and choices:

Python · Scene Functions

Notice how scene_hallway has a random event — 50% chance of finding money, 50% chance of the backpack situation. This uses random.random() which gives a decimal between 0 and 1. The game is different every time you play.

Step 5: The Full Day

Let's add the remaining scenes and connect them into a complete game:

Python · The Complete Game

Play it through! Then play again and make different choices — the story, the stats, and the ending will all change. Every playthrough is different because of the random events and your decisions.

Every Skill in One Game

Let's count the skills this game uses:

The Full Toolkit

Lesson 1 — Decomposition: We broke the game into components: engine, scenes, stats, ending

Lesson 2 — Abstraction: We modeled a student with just 4 stats out of infinite possibilities

Lesson 3 — Deductive Reasoning: If/elif/else chains determine consequences and endings

Lesson 4 — Categorization: Choices organized as lists of dictionaries

Lesson 5 — Pattern Recognition: The choice→consequence→stats pattern repeats in every scene

Lesson 6 — Automation: One make_choice() function handles ALL choices

Lesson 7 — Inductive Reasoning: Random events make each playthrough different

Lesson 8 — Functions: Scenes are functions. Stats display is a function. Everything is organized

Lesson 9 — Generalization: make_choice() works for ANY situation with ANY options

Lesson 10 — Systems Thinking: Input → choices → stats → ending is a pipeline

Lesson 12 — Data Modeling: Player is a dictionary. Options are dicts. The game is structured data

Lesson 13 — Debugging: If something breaks, you know how to find and fix it!

Every single concept from the course appears in this game. You didn't just learn isolated skills — you built a toolkit that works together.

Making It Your Own

The game above is a foundation. Here's how to extend it — each modification uses skills you already have:

Python · Ideas for Expanding

What You Just Did

You built a complex, interactive game with multiple scenes, branching choices, stat tracking, random events, and multiple endings. And you did it by combining skills you've been learning one by one over 15 lessons.

This is how real software gets built. Not by knowing everything at once, but by knowing many small things and putting them together. A web app is just functions, data, and logic — organized well.

The Big Idea

Complex things are made of simple parts. You don't need to learn something "advanced" to build something impressive — you need to get good at combining the basics. The kid who knows variables, functions, loops, and dictionaries really well can build almost anything.

Thinking Questions

  1. Which thinking skill (decomposition, abstraction, etc.) did you use the most while building or playing this game?
  2. If you could add one more scene to the game, what would it be? What choices would you offer?
  3. How is building a game similar to solving any big problem? (Hint: break it down, build the pieces, connect them.)

Level Up

Challenge 1 · Add Two Scenes

Write two new scene functions (maybe "gym class" and "bus ride home") with at least 3 choices each. Add them to the game flow. Make sure the choices affect stats in interesting ways.

Challenge 2 · More Endings

Add at least 3 more possible endings. Ideas: "The Class Clown" (high friendship, low grades), "The Mystery" (all stats exactly 5), "The Overachiever" (everything above 7). Make the ending messages fun and specific.

Challenge 3 · Two-Day Version

Make the game span two days. After Day 1, show a "night" scene where the player can rest (restore energy) or study late (boost grades but lose energy). Then Day 2's scenes should reference choices from Day 1. Use the choices_made list to check what happened earlier.

What You Learned

Thinking Skill

Synthesis & Integration — combining multiple thinking skills and coding techniques to create something complex. The whole is greater than the sum of its parts.

Game Architecture

Player model — dictionary with stats

Choice engine — one general function for all decisions

Scene functions — each scene is self-contained

Random events — different experiences each playthrough

Conditional content — scenes adapt based on current stats

Multiple endings — final state determines the story

Stat clampingmax(0, min(10, value)) keeps numbers in range