Counting and sampling a combinatorial space without enumerating it

Plenty of features hide a space of combinations too large to write out: product configurations, generated test inputs, procedural levels, expression generators. We ran into this while building Generative Grammar Engine , where three questions kept coming up. None of them should need the whole space built first: how many possibilities exist, draw a random one, list a few distinct ones. A generative…