AI GAME GENERATOR · REPEATABLE LEVELS
Why Does My AI Game’s Level Change Every Time?
Use a fixed seed, the same saved generator code, and identical inputs and random-call order. A seed can reproduce a procedural layout; it does not make an AI regenerate identical code.
If your AI game generator makes a different level on restart, first separate two actions: running the existing game and asking the AI to rewrite it. A repeatable random-number stream helps with the first. Keeping the actual source and build is essential for the second.
What a fixed seed can and cannot repeat
A seeded pseudorandom generator follows a repeatable sequence. Your layout code chooses how to consume it. If another feature consumes the next number first, the terrain receives a different part of the sequence. The seed may still be correct even when the map changes.
JavaScript’s built-in Math.random() does not expose a user-selectable or resettable seed. Asking an AI to “set Math.random to 42” is therefore not a complete implementation. Use an explicitly seeded generator for the layout, and check which parts of the project actually use it. See MDN’s Math.random documentation.
Four runs with a recorded recipe
I ran an isolated JavaScript obstacle-map model. It fills an eight-column, six-row grid from left to right, then top to bottom. Each cell consumes exactly one random number. Values below 0.25 become an obstacle; other cells stay empty. The model checks reproducibility only: it does not create a playable route, test difficulty, or evaluate Luddi, SeaVerse, or Star.
The random state is an unsigned 32-bit integer. Each draw computes state = (1664525 × state + 1013904223) modulo 2^32 and divides the result by 2^32. The implementation uses Math.imul and an unsigned shift to keep those integer semantics explicit. This simple linear congruential generator is an illustration, not a recommendation for security or every production game.
Run A: seed 42, v1
Map checksum prefix:bd23ed79864a
Baseline recipe
Run B: seed 42, v1
Map checksum prefix:bd23ed79864a
Exact repeat: same map
Run C: seed 43, v1
Map checksum prefix:2ef9e4ced6f4
Changed seed: different map
Run D: seed 42, v2
Map checksum prefix:308d05d2b1b5
One extra draw: different map
Runs A and B produced identical map text and identical SHA-256 checksums. Run C changed only the seed to 43 and produced another map. Run D kept seed 42 but used version two, which discards one random draw before filling the grid. That one change shifted the sequence and changed the map. These are measured outputs of this small model, not a claim that every different seed must always produce a different finite map.
Try the exact baseline
This minimal snippet reproduces run A in JavaScript. Each call starts with a fresh local state, so a previous run cannot accidentally advance the next run’s generator. It returns the map text rather than modifying your game. A dot means empty space and a hash means an obstacle.
// Reproduce the isolated 8 by 6 obstacle-map baseline.
function exampleMap(seed = 42) {
let state = seed >>> 0;
const rows = [];
for (let y = 0; y < 6; y++) {
let row = '';
for (let x = 0; x < 8; x++) {
state = (Math.imul(1664525, state) + 1013904223) >>> 0;
row += state / 4294967296 < 0.25 ? '#' : '.';
}
rows.push(row);
}
return rows.join('\n');
}
Expected baseline:
.#.#.#.#
.......#
#....#..
..#..##.
........
..##.#..
Keep a reproduction packet, not just a number
For this experiment, the packet contains seed 42, generator version one, the saved source, width eight, height six, obstacle threshold 0.25, row-major iteration and one draw per cell. I also saved the map text and its checksum. Together these identify what was compared. A screenshot is useful for humans, but a map file lets you compare cells directly.
For your actual game, add the build identifier, relevant assets and settings, and the action that starts generation. Keep layout randomness separate from cosmetic effects when possible: adding a random sparkle should not silently move a wall. Separate streams still need recorded algorithms and seeds; merely naming a variable “terrainSeed” does not isolate it.
A bounded prompt for your AI game generator
Duplicate this project. Keep the existing controls, scoring, artwork and game rules. Identify all random calls used to build the starting layout. Add a debug seed input for that layout using an explicitly seeded generator. Save the generator source version and all layout inputs. Run seed 42 twice from a fresh state, export the two maps, and compare them cell by cell. Then run seed 43. Report actual outputs and any mismatch; do not claim success from screenshots alone. Do not regenerate unrelated code.
If the tool cannot expose the seed or export map data, keep the original build and describe that limitation. Do not present a visually similar level as a deterministic replay. Before sharing, also check the exit is reachable: repeatability says nothing about whether a level is solvable.
A real debugging question behind this test
A developer on Game Development Stack Exchange reported differing results despite a constant seed, then noted that the random generator was called more times in some executions. That is a useful failure pattern to investigate, not evidence of a bug in an AI product. Source: the LibGDX same-seed question.
Fixed-seed questions
Does the same seed guarantee the same level after an update?
Only if the relevant generation behavior and inputs stay equivalent. Keep the old generator version or save the generated layout when exact compatibility matters.
Will the same AI prompt recreate my old game?
Do not rely on that. Preserve the existing code and build. A procedural layout seed controls a program’s random sequence; it is not a promise about an AI service’s next response.
Does a seed save player changes to the world?
No. A seed describes the initial generation recipe. Broken walls, collected items and other player changes need their own saved state or change log.