MicrolearnENPTES

Seeds make it repeatable

Lesson 14 of 16 · GDev.Micro

Pure randomness has a cost. You cannot share a good level, reproduce a bug or run a daily challenge, because the next run is always different.

Computers do not make true randomness. They use a pseudorandom generator: a formula that turns one starting number, the seed, into a long sequence that looks random. Same seed, same sequence, same level.

Set the seed before generating. Then press Restart a few times: the coins land in the same places every run. Remove the seed and they move again.

The built-in random expressions in GDevelop give different results on every run. Projects that need repeatable levels use a seeded generator, built with variables and events or taken from a community extension.

Make the generated level identical on every run: set the seed to 42 before generating.

Do it in the browser: a real game design tool, a short mission and instant feedback. No install.

Start this lesson — free
← Randomness and RepeatRules and constraints →

All lessons · GDev.Micro