A region is counted by spreading to its four neighbours. Follow each wave, count the reached cells, and see why one region becomes territory.
GO STRAIGHT TO THE EXPLANATION
Try a completed line, then advance the spread.
01 / THE GAME
1 · territory2 · trail3 · player4 · enemy
Enter · play / resume · P · pause Hold one arrow to move. Leave territory to draw. Return to blue territory to close the line. An enemy touching the trail ends the attempt.
This teaching board has 16 × 24 cells. The book uses 32 × 48; the Boolean-layer and region rules are the same. Initial enemy positions are reproducible here.
Every direction reads the same previous state. A wave adds cells one step farther away. When no new cells appear, the region is complete.
04 / COMPARE THE FINISHED REGIONS
Region
Area
Enemy?
Decision
A completed line becomes territory. Then examine the remaining free regions.
As in the book: if the line creates more than one region, capture the smallest region without enemies. A tie chooses the last equal candidate in scan order. Other regions are excluded from this search, but do not become territory.
FOUR BOOLEAN LAYERS
The drawing changes. The masks explain why.
The field keeps territory, unfinished trail, player and enemy layers separate. After closing a line, a temporary blocked mask starts from territory. Each complete region is added to blocked, so it is examined only once.
Choose “Two regions”. Before spreading, predict the area on the left. Count the interior rows and columns, then compare their product with region.sum(). Next try “Choose the smallest”: an empty region is eligible, but only the smallest eligible region is captured.
JavaScript adaptation of Module 18. Growth is deliberately animated; the Python program completes it within one update. Movement is slowed for inspection. The browser pauses on a loss and waits for Restart; the book restarts automatically. Capture completion is measured over interior cells, with a 75% target.