Help with procedural level

When I generate a world, I’m getting a strange bug when I use the select action, where it generates multiple or no tiles of a specific type.

Se here, if I type the coordinates manually, it generates perfectly fine.




But when I use the select action, it sometimes generates zero or more than one tile.



Perhaps it’s about the way evaluation of random works. It will generate a new value every time it’s accessed. To greatly simplify the issue:

The chances the above prints the same number are pretty slim, we actually generate an integer twice. The below would work differently, though:

We’re generating a random value only once.


Could this be the issue you’re experiencing? Hard to tell from the snippet how the entire thing operates but I’d blame getting inconsistent result from random (the irony, eh?!) on the evaluation logic.

In short: if you’re running a loop asking for a random bool, you will get a random one with each iteration, not with each loop.

2 Likes