Under the Hood: Your code is executed by real CPython 3.11 compiled to WebAssembly (Pyodide). Python calculates your algorithms and streams action packets across the Foreign Function Interface (window.pyBridge). The JavaScript Host consumes those packets to drive the 60 FPS HTML5 Canvas engine, update DOM telemetry, and synthesize procedural Web Audio!
1. Rover Navigation & Drilling
rover.drill() # Drills tile in front of the rover
rover.move_down() # Moves the rover down 1 tile
rover.move_up() # Moves the rover up 1 tile
rover.move_left() # Moves the rover left 1 tile
rover.move_right() # Moves the rover right 1 tile
rover.collect() # Collects Emeralds, Lithium, or Bonus Pieces (Crown/Ruby/Diamond)
for layer in range(6):
rover.drill()
rover.move_down()
4. Cargo Lists & len()
# rover.cargo is a Python list of collected strings
print(rover.cargo) # -> ['Lithium Core', 'Emerald Geode']
total = len(rover.cargo) # -> Number of items
5. Subsystem Dictionaries
# rover.systems is a Python dictionary
rover.systems["torque"] = 90 # Overclock torque to pierce titanium armor!
rover.systems["shield"] = 100
while rover.battery < 80:
rover.drill()
rover.move_down()
rover.collect() # Recharges at Power Cells
8. List Comprehensions
# Filter lists in a single elegant line:
emeralds = [item for item in rover.cargo if "Emerald" in item]
print("Found Emeralds:", len(emeralds))
9. Tuples & Path Coordinates
route = [("DOWN", 2), ("RIGHT", 2), ("DOWN", 1)]
for direction, steps in route:
for _ in range(steps):
rover.move_down() if direction == "DOWN" else rover.move_right()
10. Master Protocol (Combining Systems)
rover.systems["torque"] = 90 # Overclock systems
if rover.scan_down() == "MAGMA":
rover.move_right() # Radar safety detour