Back

Code Challenge: Build Your Own Dungeon Crawler

Difficulty  

divider

Objective

In Activity 1.12 you built my dungeon crawler — the thunderstorm, the cave, the Twinkie, the wolfpack and the dragon.

Now build your own. Same machinery, completely different story. Set it wherever you like: a haunted school, a space station, a sunken ship, the inside of a vending machine. The only thing you are keeping is the structure.

Skills to Practice

  • Nesting conditionals several levels deep
  • Planning branches before writing code
  • Tracking state with boolean flags and counters
  • Handling input that does not match any option

Tasks

  • Create a new Python program named cc-build-your-own-dungeon-crawler.
  • Plan it first. Sketch your branches on paper before you type anything — every choice, and what each answer leads to.
  • Write an opening that sets the scene and ends in the player's first choice.
  • Offer at least two different paths from that first choice.
  • Nest at least two levels deep — a choice inside a choice, the way the Twinkie sat inside whichever path you picked.
  • Include one item or resource the player can pick up, and make it matter later. Keys, batteries, snacks, whatever fits your story.
  • Track how the story ended with boolean flags, the way wolfpack_ending and dragon_ending did.
  • Write an ending that reports what happened, based on those flags and anything the player collected.
  • Every choice needs an else for input you did not expect. Do not let one typo silently skip your whole story.
  • Call .lower() on your inputs so LEFT, Left, and left all work.

Build it the way Activity 1.12 taught: sketch the skeleton with pass in every empty branch first, confirm the shape runs without crashing, then fill the branches in one at a time. Writing a whole branching story top to bottom in one go is how you end up with indentation you cannot untangle.

Stretch Goals

  • Three or more endings instead of two.
  • An ending only reachable if the player collected the right item.
  • A choice that looks appealing and quietly ends the story early.

Keep it school-appropriate. The sample below shows the shape only — do not reuse the story.


Sample Output

Sample Output
The vending machine hums as you drop in your last quarter.
Nothing comes out. The front panel slides open instead.
Inside, two dimly lit tunnels lead away from you...
Which tunnel do you take? (left or right) -> LEFT [Enter]
You squeeze left. Something crunches underfoot - a bag of chips.
Do you take it, or eat it now? (take or eat) -> take [Enter]
You pocket the chips. The tunnel opens into a room full of coin slots.
A rusted robot blocks the exit. It looks hungry.
Do you offer the chips, or run? (offer or run) -> offer [Enter]
The robot accepts your tribute and rolls aside.
You escape into the daylight, 3 quarters richer.
--- THE END ---
Escaped the machine: True
Befriended the robot: True
Quarters collected: 3
Snacks remaining: 0

Commence Challenge