Checkpoint

Checkpoint: Scout the Harbour

A storm has blown fog over Driftwood Harbour. The Guild needs Pip to scout the docks and report back with a map.

This checkpoint uses the whole chapter: maps as lists of strings, (row, col) positions, deltas, edge checks and rocks.

Assignment

  1. can_enter(world, pos) returns True if pos is inside the map and its tile is not "#". Otherwise False. Check "inside" first, so you never read a tile that isn't there.
  2. walk(world, pos, delta) returns the new position if Pip can_enter it. Otherwise it returns pos unchanged.
  3. render(world, pos) returns a new list of rows with "P" at pos.

The program at the bottom tries east (a rock!) and then south. Pip should end up in row 2, column 1.