Sign up and get 15% off the four courses and Lifetime.

Generative design

Lesson

Parameters, constraints and seeds

Lesson 2 of 10 in Generative design.

Lesson

Every generative system runs on three kinds of setting. Parameters are the values the system is allowed to change. Constraints are the things it may never do. The seed is a number that makes its randomness repeatable, so you can make the same output twice.

The balance between the first two decides whether a system makes designs or noise. The example here is a coffee roaster that wants a different pattern of scattered circles on the label of every batch it roasts, with every label clearly from the same brand.

Keep the parameter list short and the constraint list long

Beginners write long lists of things that can vary and short lists of things that cannot, and the system they get makes noise. Good systems are the other way round. Each constraint removes a huge range of possible outputs, and what remains is the thing you actually designed.

For the coffee labels, the settings might look like this.

SettingKindFor the coffee labels
Number of circlesParameterFour values to test
Largest circle sizeParameterFour values to test
ColoursConstraintOnly the roaster's four brand colours
MarginConstraintNo circle crosses the edge margin
Logo and batch numberConstraintAlways in the same place, never covered

The same habit carries over to prompts for image tools. A prompt is a set of parameters plus a do-not list, and the do-not list does most of the work.

Explore one parameter at a time

Parameter space means every combination the system allows, and it is usually far bigger than anyone looks at. If you try random combinations, you keep landing in the middle. Vary one parameter at a time and lay the results out in a grid, and you will find the interesting corners in an hour.

The p5.js web editor at editor.p5js.org is an easy place to do this. p5.js is a free, open-source JavaScript library, and the editor runs in a browser with nothing to install, though you need a free account to save your work.

Take the circles sketch and pick four values for the number of circles and four for their largest size. Draw all 16 combinations on one canvas, and label each cell with its two values and its seed. If the code is new to you, a chat model will write the loop.

Add the constraints before you tune anything

Put the constraints into the code first, which for the roaster means the fixed palette and the margin no circle may cross. Only then start adjusting the parameters. Constraints narrow the system down to what you designed, while parameters only widen it, so tuning before the limits are in place means tuning the wrong thing.

Once the first grid already uses only the four brand colours and keeps every circle inside the margin, any cell that still looks wrong is telling you something about the parameters. Change those, one at a time.

Fix the seed and test it

In p5.js you call randomSeed() with a fixed number at the start of the sketch. The p5.js reference says a constant seed makes random() give the same results on every run, so any cell in your grid can be made again exactly.

Now change the seed and draw the grid again. If each cell keeps its character with the new seed, the rule is doing the work. If the cells change completely, the randomness is doing it, and you need more constraints.

Save every keeper with its seed

A system you cannot repeat is no use to a client, because a client will always ask for the one that went past. Save each version you keep with its seed and its values in the file name, such as "label_circles-40_size-30_seed-2741". When the roaster asks for the label from Tuesday's grid, you can rebuild it in seconds.

The next lesson looks at identity systems that generate themselves.