Star-Shaped Region Constraints as Tractable Global Propagators for Grid Generation

Many grid problems need a region with a global shape: a room enclosed by walls in a generated game level, a walkable zone in which every point can reach a landmark, or an organ in a segmentation mask that must be one solid piece. Constraint solvers handle such problems with local consistency. Local consistency means each constraint deletes, on its own, the values that cannot appear in any assignment satisfying that single constraint. Because each constraint looks only at its own variables, this kind of reasoning cannot see whole shapes. WaveFunction Collapse (WFC), a tile-based level generator, is the standard example. It checks small tile windows, so it cannot ensure that a room closes up or that a path exists. The usual fix, hierarchical multi-pass generation, still offers no guarantee that the level is solvable. This proposal adds a single global constraint, StarRegion, which requires that the cells marked "inside" form a star-convex region around a center cell. Star-convex means every inside cell is joined to the center by a straight digital line that stays inside the region.

The proposal rests on one structural observation. Once the center is fixed and each cell's "next step toward the center" is fixed, star-convexity becomes a tree constraint: a cell can be inside only if its parent is inside. Requirements that are intractable for sequence-style global constraints, such as an exact area or additive per-cell costs, become polynomial on this tree through dynamic programming. The result is a propagator that achieves domain consistency for star-convexity together with an exact area constraint. Domain consistency means every value left in a domain belongs to some full solution of the constraint. The constraint also gives connectivity for free, so the generator can guarantee that a path exists.

Core Claim

Fix a center $c$. Let $\pi_c(p)$ be the cell one step closer to $c$ along a fixed digital ray from $c$ through cell $p$. The rays are built so that every cell has exactly one parent, which makes $\pi_c$ a tree rooted at $c$. Write $x_p \in \{0,1\}$ for whether cell $p$ is inside. StarRegion with area between $a_{\min}$ and $a_{\max}$ is then

$$x_c = 1,\quad x_p \le x_{\pi_c(p)} \ \ \forall p,\quad a_{\min} \le \textstyle\sum_p x_p \le a_{\max}.$$

The feasible regions are exactly the rooted subtrees of the ray tree that respect the cells already fixed in or out. We claim three results.

First, domain consistency for this conjunction can be enforced in $O(N \cdot a_{\max})$ time per center, where $N$ is the number of cells. This uses tree-knapsack dynamic programming: compute, bottom-up and top-down, which subtree sizes are achievable with each cell fixed in or out.

Second, when the center is itself a variable with domain $D(c)$, domain consistency costs $O(|D(c)| \cdot N \cdot a_{\max})$. A value is supported if it is supported for some center.

Third, every solution is 4- or 8-connected through its ray paths. Two cells inside the same region are therefore joined by an inside path through $c$. Chaining overlapping StarRegions yields a reachability guarantee.

The second claim needs care. Polynomial time requires a small center domain, which is why the program supplies center candidates rather than leaving the center free over the whole grid. The first claim is the one with theoretical bite. Beldiceanu et al. showed that enforcing an exact count inside regular-language counting constraints is NP-hard, by reduction from Subset-Sum (reported in the file without a citable link). Exact area becomes tractable here because the dependency structure is a tree rather than a sequence with automaton state.

Relation to Prior Work

Three papers supply the method and the motivation.

K-convexity Shape Priors for Segmentation shows that growing or shrinking one star-convex part while the other parts stay fixed is a submodular energy problem, solvable exactly by graph cuts. Our observation explains why: star-convexity with a fixed center is a set of pairwise implications. That paper minimizes an energy and never returns pruned domains, so it cannot cooperate with other constraints inside a solver. It also notes that it lacks a formal connectivity guarantee, which the tree structure provides here.

Polynomially Decomposable Global Cost Functions in Weighted Constraint Satisfaction shows that global cost functions which break down into polynomial dynamic-programming tables support tractable cost projection. We reuse that idea on a spatial tree; their experiments were on sequence benchmarks.

Convexity Shape Prior for Segmentation penalizes non-convex pixel triplets along lines and computes the energy with running sums along each line. Regular convexity is non-submodular, and their trust-region solver is local. Our choice of star-convexity is deliberate: it is the tractable side of the boundary that Isack et al. identified.

Two other papers constrain the design and show the pattern we follow. Propagating Conjunctions of AllDifferent Constraints and The AllDifferent Constraint with Precedences both show that combinations of individually easy constraints become NP-hard. The first finds that the hardness disappears under a structural restriction, namely interval (one-dimensional convex) domains. The second escapes it by relaxing to bounds consistency, which leaves impossible interior values in the domains. We follow the same pattern with a spatial restriction, star shape around a known center, and we obtain full domain consistency rather than bounds consistency.

The application regime comes from Hierarchical WaveFunction Collapse. It places coarse structure using "Unfilled" placeholder tiles and states openly that it cannot guarantee level solvability. StarRegion replaces hand-authored placeholder hierarchies with a declarative constraint that carries a proof of connectivity.

The center-selection problem shared by k-convexity and by the differentiable star prior of Convex Combination Star Shape Prior is handled with the medoid idea from Embedding-based Instance Segmentation in Microscopy. The medoid is the object cell that minimizes average distance to all other object cells, so unlike the centroid it always lies inside the object. We use it only to produce small candidate center domains.

Research Program

The first stage is theory. We will prove the domain-consistency algorithm correct for the area-bounded tree. We will extend it to additive unary costs in the weighted setting, following the style of Lee et al.: tree dynamic programming absorbs unary cost moves, which should give a polynomial weighted-CSP propagator. We will also characterize what breaks.

Three cases are open. Two StarRegions with different centers that share cells: we conjecture this is NP-hard with exact areas, analogous to overlapping AllDifferent constraints, and is tractable with bounds only. Adding pairwise boundary costs between grid neighbors: this breaks the tree structure. Changing the ray-tree construction: digital lines do not nest perfectly, so "star-convex" here means "star-convex with respect to a fixed ray tree". We will measure how far this definition deviates from the triplet-based definition on random shapes.

The second stage is engineering. We will build an incremental propagator that updates the dynamic-programming tables only along tree paths affected by a domain change. It will also produce explanations, meaning a small set of fixed cells responsible for each pruning, so that a clause-learning solver can use it. A StarChain constraint will compose $k$ regions whose consecutive members must share at least one cell. This turns per-region connectivity into start-to-goal reachability.

The third stage is integration. We will place StarRegion and StarChain inside a WFC-style constraint model, with tile adjacency as table constraints, and inside a weighted-CSP segmentation model. Center domains will come either from designer-specified landmarks or from the medoid of a coarse mask.

Baselines

The naive reference point is plain WFC with restart on contradiction, using the HWFC paper's tile sets for its Maze and Roguelike domains. It is given the same wall-clock budget per level. A generated level counts as solvable only if a breadth-first search later confirms a start-to-goal path.

The strongest existing method for global structure in this setting is Hierarchical WaveFunction Collapse. We will run it with the same tile sets, a hierarchy of comparable effort authored by us, and the same time budget. No reported result was found on Lacuna for HWFC solvability rate, and its container-placement fraction is reported only qualitatively. We will therefore measure both metrics ourselves for both systems. Beating HWFC means a 100% guaranteed solvability rate at equal or lower generation time per level, with diversity (the KL-divergence measure from the HWFC paper) no worse than HWFC's.

The key ablation isolates the global propagator. The same constraint model is run with StarRegion decomposed into its pairwise implications plus a separate sum constraint, each propagated locally. Every solver setting, branching heuristic, and time limit stays the same. With a fixed center and no area bound, this decomposition already achieves domain consistency, so we expect no gain in that case. Any difference must appear once exact area, costs, or a center variable is added. Beating the ablation means at least an order of magnitude fewer backtracks on instances with tight area and tile-adjacency constraints, and lower total solve time. The oBC propagator for overlapping AllDifferent constraints set a comparable bar: backtracks were reduced "by multiple orders of magnitude" and total time was "2 to 5 times faster" Propagating Conjunctions of AllDifferent Constraints.

A secondary baseline is generate-then-reject: run plain WFC repeatedly and discard unsolvable outputs. The comparison is time to the first solvable level under a matching constraint set.

On the segmentation side, the baseline is the k-convexity method with star-convex parts K-convexity Shape Priors for Segmentation. It is run on the same 12-subject liver CT data with the same seeds. It reports an $F_1$ score of 0.73–0.79 at 20° shape tightness. We do not expect to beat it on accuracy, because we drop its pairwise boundary terms. The test is whether adding an exact-area or volume-range constraint with domain-consistency pruning improves $F_1$ when the volume is approximately known.

Why not just…?

Why not just decompose star-convexity into binary implications and let a clause-learning solver handle the rest? This is the most serious alternative, and in the fixed-center, no-area case it is simply correct. The decomposition is already domain consistent there, and we will report that rather than claim a gain. The decomposition fails when the area is constrained. Local propagation of the sum sees only how many cells are still undecided, not which subtrees can actually be completed. It therefore keeps cells that would force an area violation through their ancestors or descendants. Conjunctions of overlapping AllDifferent constraints Propagating Conjunctions of AllDifferent Constraints show the same separation between local and joint reasoning. The ablation above settles the question empirically. If clause learning closes the gap on our instances, the contribution shrinks to the connectivity guarantee and the theory.

Why not just use a hierarchical generator like HWFC? HWFC improves where macro-structure is placed, but its authors state that it cannot guarantee a traversable path. It also needs hand-authored placeholder rules Hierarchical WaveFunction Collapse. StarChain gives a guarantee that holds by construction. The comparison measures whether that guarantee costs diversity.

Why not just generate freely and reject unsolvable levels? Rejection works when solvable levels are common. It degrades sharply as constraints tighten, because the acceptance rate falls. The time-to-first-solvable-level experiment, run while sweeping area tightness and the number of required landmarks, shows where rejection stops being viable. If rejection remains competitive across the whole sweep, we will say so.

Why not just add a general connectivity constraint instead of a shape constraint? General connectivity is the expensive global constraint that k-convexity explicitly avoided K-convexity Shape Priors for Segmentation. Star-shape is a stronger requirement than connectivity, and it comes with tractable exact-area reasoning. The trade-off is expressiveness: branching shapes need several overlapping regions. We will report how many regions typical Roguelike room layouts require.

Decisive Checks

The first check is a generation sweep on the Maze and Roguelike tile sets with grids from 20×20 to 80×80. It varies area tightness (exact area against a ±20% range) and center-domain size (1, 5, and 25 candidates). It records solvability rate, backtracks, solve time, and KL-divergence diversity against all baselines. The proposal succeeds if two things hold. StarChain reaches 100% solvability while WFC and HWFC fall short. The full propagator beats the decomposed ablation by an order of magnitude in backtracks, but only in the configurations with area constraints or a center variable, as the theory predicts.

The second check is scaling. We will confirm the predicted $|D(c)| \cdot N \cdot a_{\max}$ growth and find the center-domain size at which the propagator stops paying for itself.

The third check is a complexity result for two overlapping StarRegions with exact areas, either a polynomial algorithm or an NP-hardness reduction. This result decides whether the shared-cell chains in StarChain can keep domain consistency or must fall back to bounds.

The fourth check is a secondary run on liver CT using medoid-derived centers, which tests whether exact volume pruning transfers to segmentation.