topskill.dev
CoursesTracks
0
All courses/Python Basics: The Lantern AtlasFinal Game Mission: Open the Exit Gate
Level 11: Exit Gate — Putting It Together
2 / 3
← Python Basics: The Lantern Atlas
○Level 1: Spawn Camp○Demo: Light the Camp Message○Exercise: Open the Lantern Map○Code Comments○Demo: Name a Map Location○Exercise: Label a Beacon○Variable Types○Demo: Inspect Lantern Types○Exercise: Pack Starting Supplies○Optional: Set up Python Locally✦Module Quiz
○Demo: Divide Beacon Shards○Exercise: Price a Cache Route○Demo: Format a Gear Label○Exercise: Format Forge Readouts○Demo: Convert Shard Text○Exercise: Convert Charge Readings○Demo: Read a Pathfinder Name○Project: Build Adi’s Gear HUD✦Module Quiz
○Demo: Compare Workshop Supplies○Exercise: Check Gate Supplies○Demo: Choose a Lit Route○Choose a Gate Signal○Demo: Pulse a Beacon with while○Exercise: Recharge the Beacon○Demo: Mark a Route with range○Exercise: Label Even Patrols○Demo: Skip a Hazard, Stop at a Gate○Exercise: Cross Safe Tiles○Project: Unlock the Exit Gate✦Module Quiz
○Define a Beacon Ability: Demo○Exercise: Activate a Beacon○Pass Energy and Return a Result: Demo○Exercise: Combine Beacon Energy○Default Ability Marks: Demo○Exercise: Name a Beacon Ability○Local Energy Scope: Demo○Exercise: Spend Local Energy○Project: Build an Ability Loadout✦Module Quiz
○Read a Rune Code: Demo○Exercise: Read Rune Edges○Slice a Cavern Route: Demo○Exercise: Decode Route Fields○Clean a Rune Message: Demo○Exercise: Decode a Rune Notice○Format a Route Card: Demo○Exercise: Write a Decoded Route Sign✦Module Quiz
○Index a Gear List: Demo○Exercise: Build a Gear Queue○Change a Gear List: Demo○Exercise: Repair the Loadout○Slice a Ridge Route: Demo○Exercise: Pack for Checkpoints○Read a Fixed Checkpoint Record: Demo○Exercise: Read an Exit Checkpoint✦Module Quiz
○Read an Atlas Map Card○Exercise: Update a Map Entry○Loop Through Beacon Map Entries○Exercise: Count Cache Marks○Count Unique Atlas Stops○Exercise: Compare Atlas Routes○Demo: Summarize Beacon Finds○Exercise: Build the Atlas Treasure Index✦Module Quiz
○Recover a Faded Beacon Reading○Exercise: Label Beacon Charge○Demo: Write a Shrine Save○Exercise: Save a Beacon Signal○Mini Project: Restore the Save Shrine✦Module Quiz
○Demo: Calculate Beacon Capacity○Exercise: Calculate Lantern Capacity○Demo: Import a Local Beacon Rule○Exercise: Import a Shrine Rule○Demo: Follow a Dotted Package Import○Exercise: Read an Atlas Record✦Module Quiz
○Echo Tower: The Base Case○Echo Tower: Sum the Signals○Echo Tower: Tune the Frequencies○Echo Tower: Select Beacon Labels✦Module Quiz
○Exit Gate: Reading Object Vocabulary●Final Game Mission: Open the Exit Gate✦Module Quiz

Final Game Mission: Open the Exit Gate

The Exit Gate stays locked until every beacon has enough signal strength. Your final program will read commands, charge the known beacons, and report whether Adi can leave the Atlas. The starter supplies a list of player commands, so Run does not wait for keyboard input.

A command looks like "north:2". Accept spaces and lowercase names, but ignore a malformed command, an unknown beacon, or a strength of zero or less. Repeated valid commands add strength. The supplied beacons dictionary gives each beacon's required charge.

Work on one helper at a time in main.py. Run prints helper checkpoints while play_mission is unfinished; an unfinished helper may show None. Submit after each task. You do not need classes, enums, recursion, or lambdas.

Split a command into two parts

text.split(":", 1) returns a list, splitting at only the first colon. Check that it has two parts before unpacking. An extra colon stays in the second part, so converting that part with int() raises ValueError.

Run this small delivery example. Notice the two-item list, the missing separator, and the invalid numbers:

python
for text in [" dock :3", "dock", "dock:3:4", "dock:many"]:
    parts = text.split(":", 1)
    print(parts)
    if len(parts) != 2:
        print("Missing separator")
        continue
    place, amount_text = parts
    try:
        amount = int(amount_text)
        print(place.strip().upper(), amount)
    except ValueError:
        print("Invalid amount")

For your game, also reject an empty name and strengths of zero or less. Build and Run each helper before moving to the next task.

Helper checkpoints

parse_command returns a (NAME, strength) tuple. Strip spaces from the name and uppercase it; convert the strength inside try/except ValueError. Return None for a malformed command, an empty name, or a strength of zero or less. For example, " north:2 " becomes ("NORTH", 2).

charge_beacons starts each known beacon at zero. Loop through the commands, call parse_command, and add valid strengths to known names. Ignore invalid commands and unknown names. Return the charge dictionary.

gate_open uses a condition and a loop to check every required charge. An empty beacon dictionary returns False. A missing or insufficient charge also returns False; return True only when all requirements are met.

play_mission uses your helpers and returns a list of lines. Keep dictionary order and format each beacon as "<NAME>: <charge>/<required>". Add one final line:

  • On a win: "Exit Gate: OPEN - Adi leaves the Lantern Atlas with every beacon bright."
  • Otherwise: "Exit Gate: LOCKED - Restore every beacon to continue."

Your Task

  1. Complete parse_command(command) to return a valid command tuple or None.
  2. Complete charge_beacons(beacons, commands) to return accumulated charges using parse_command.
  3. Complete gate_open(beacons, charges) to check the gate condition.
  4. Complete play_mission(beacons, commands) to return the report and ending using your helpers.

Once the full mission runs, remove one valid command to try the locked ending. Restore the command and Submit again to finish.

Take the Quiz →
Files
  • ⋄main.py
Loading editor…
Press Run to execute your code.