
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
can_enter(world, pos)returnsTrueifposis inside the map and its tile is not"#". OtherwiseFalse. Check "inside" first, so you never read a tile that isn't there.walk(world, pos, delta)returns the new position if Pipcan_enterit. Otherwise it returnsposunchanged.render(world, pos)returns a new list of rows with"P"atpos.
The program at the bottom tries east (a rock!) and then south. Pip should end up in row 2, column 1.
can_enter(world, pos)returnsTrueifposis inside the map and its tile is not"#". OtherwiseFalse. Check "inside" first, so you never read a tile that isn't there.walk(world, pos, delta)returns the new position if Pipcan_enterit. Otherwise it returnsposunchanged.render(world, pos)returns a new list of rows with"P"atpos.
The program at the bottom tries east (a rock!) and then south. Pip should end up in row 2, column 1.
main.py Python sleeping
Press Run to try your code, then Check to test it.