Skip to content

Lesson 04 — Build the playable wall path ​

Where this lesson fits: the player can move, but movement still needs a single source of truth for where walking is allowed. The path is derived from unclaimed tiles and rebuilt after a claim.

Time: 4–6 hours

Prerequisites and outcomes ​

Complete lessons 02–03. By the end, you can build the initial path, test containment, snap a position to it, and explain when a rebuild is required.

Prepare and run ​

  1. From your learner project's solution folder, follow tutorial chapter 04 steps 1–5.
  2. Open Tests\Systems\WallSystemV2Tests.cs; find RebuildPlayablePath_AfterClaim_MatchesRemainingPlayableRegion. Its fixture claims six tiles and asserts path.Contains(new Vector2(12, 4)) is true while path.Contains(new Vector2(2, 2)) is false.
  3. Run the focused commands below, then follow the tutorial's checkpoint. Capture gameplay arrives in the later capture chapter; here the test applies a prepared claim.

Code anchors ​

  • last-perimeter/Source/Entities/PlayableWallPath.cs
  • last-perimeter/Source/Systems/WallSystemV2.cs
  • last-perimeter/Source/Systems/MovementSystem.cs
  • last-perimeter/Tests/Systems/WallSystemV2Tests.cs
  • last-perimeter/Tests/Systems/PlayableWallPathTests.cs

Guided operations ​

  1. Build the first path from a fresh ArenaSystem; inspect its segments and nodes.
  2. Follow Contains and Snap. Mark where tolerance is applied and what snapping guarantees.
  3. Use a test arena with claimed tiles. Rebuild and compare the resulting path with the unclaimed region's edge.
  4. Move the player toward a point on and off the path. Verify that accepted movement uses the path model rather than reinterpreting tile flags.
  5. Trace the claim handoff in lesson 08: the path must be rebuilt from the committed arena, not before.

Run the focused suites:

powershell
dotnet test --filter FullyQualifiedName~PlayableWallPathTests
dotnet test --filter FullyQualifiedName~WallSystemV2Tests
dotnet test --filter FullyQualifiedName~MovementSystemTests

Checkpoint ​

The initial path is closed, snapping returns a point on a segment, and a path rebuilt after a claim follows the remaining playable edge.

Common mistakes ​

  • Letting the player walk on claimed interior because it was once adjacent to the arena wall.
  • Rebuilding the path from an uncommitted solver result.
  • Increasing movement speed without checking whether the path tolerance still permits corners.

Questions and extension ​

Which invariants should remain true if the arena is irregular? Add a path test for a small non-rectangular fixture.