Skip to content
STIMSMITH

constraint-based generator

Technique WIKI v1 ยท 6/18/2026

A constraint-based generator models generation as a constraint satisfaction problem and samples outputs from the set of assignments satisfying the constraints. In CSP solution generation, a volume-weighted uniform spawning step combined with rejection of non-solutions can yield a uniform distribution over valid solutions.

Overview

A constraint-based generator is a generation technique that represents valid outputs as solutions to a set of constraints. In the procedural-content-generation setting, modeling generation as a constraint satisfaction problem supports both local and global constraints on generated outputs. Recent work on YORO pre-rolling describes this as a way to retain solver-based enforcement of global constraints while also shaping output statistics in WFC-like generators.

Constraint-based sampling pattern

In the CSP solution-generation formulation, let ๐’ฎ be the set of all solutions satisfying constraints ๐’ž. A sampling procedure can operate over elements whose volumes are known, selecting an element e with probability proportional to its volume v(e) and then spawning a point uniformly inside that element.

The cited construction assumes:

  • spawn(e) samples uniformly within element e, so for any point i โˆˆ e, the density is P(i | e) = 1 / v(e).
  • An element e is selected with probability P(e) = v(e) / ฮฃ v(eโ€ฒ) over the considered elements.
  • The joint probability of selecting e and spawning i is therefore constant across points in the sampled region: P(e) ยท P(i | e) = 1 / ฮฃ v(eโ€ฒ).

Rejection and validity

A spawned point may not satisfy the constraints. The procedure distinguishes elements whose points are guaranteed valid from elements that require checking:

  • If e โˆˆ โ„, all points in e satisfy ๐’ž, so the spawned point is accepted.
  • If e โˆˆ ๐’ช, the spawned point is accepted only when it belongs to ๐’ฎ; otherwise the sampling process is repeated.

This is a rejection-sampling step: invalid samples are discarded, and sampling continues until a valid solution is returned.

Uniformity property

For any particular solution i โˆˆ ๐’ฎ, the probability of returning i is the probability that it is sampled on the first attempt plus the probability that an earlier attempt fails and i is sampled later. The cited proof derives:

P(i) = 1 / ((1 โˆ’ P(fail)) ยท ฮฃ v(eโ€ฒ))

where P(fail) is the probability that a uniform element from the sampled region does not satisfy ๐’ž. Because this value is constant for every i โˆˆ ๐’ฎ, the procedure proves uniformity over the solution set.

Role in generation systems

The technique is relevant when outputs must satisfy explicit constraints while the generator should also sample solutions without bias. In solver-based procedural generation, constraint-based generators can enforce global constraints that are difficult for non-solver methods to express, while sampling and ordering techniques can be used to influence statistical properties of the generated outputs.

CITATIONS

5 sources
5 citations
[1] Constraint-based generation can model procedural-content-generation tasks as constraint satisfaction problems with local and global constraints, and YORO pre-rolling targets statistical control in solver-based WFC-like constraint-based generators. You-Only-Randomize-Once: Shaping Statistical Properties in Constraint-based PCG
[2] In the CSP solution generator, spawn(e) is assumed to sample uniformly within an element e, with P(i | e) = 1 / v(e). An Efficient and Uniform CSP Solution Generator Generator
[3] The sampler selects an element with probability proportional to its volume and then spawns uniformly inside it, making the joint point-spawning probability constant over the considered elements. An Efficient and Uniform CSP Solution Generator Generator
[4] Samples from elements guaranteed to satisfy the constraints are always accepted, while samples from other elements are accepted only if they belong to the solution set; otherwise sampling repeats. An Efficient and Uniform CSP Solution Generator Generator
[5] The probability of returning any particular valid solution is constant across all solutions, proving uniformity of the returned CSP solution. An Efficient and Uniform CSP Solution Generator Generator