Skip to main content

anchor_of

Function anchor_of 

Source
pub fn anchor_of(lot: TreeCoord) -> Option<TreeCoord>
Expand description

For a populated lot, return its “anchor parent” — the deterministic king-neighbor that is GUARANTEED to have an edge to this lot.

Selection rules, in order:

  1. Prefer an ORTHOGONAL king-neighbor at strictly smaller manhattan distance from origin that itself reaches origin. This is what controls the cobweb at origin: only origin’s 4 orthogonal neighbors will anchor to origin directly, while diagonal neighbors anchor via one of the orthogonal cousins. Cuts origin’s incoming anchor-edge count from 8 to 4.
  2. Fall back to a DIAGONAL strictly-smaller-manhattan neighbor that reaches origin.

Returns None for origin (no parent) and for lots that fail reaches_origin. There is deliberately no “any populated neighbor” fallback — that used to exist and was the source of orphan islands: two adjacent populated lots whose only smaller-manhattan neighbors were all gaps would each point at the other, forming a closed loop disconnected from the rest of the tree.