How should I go about generating a map like this?

This the the map, with the current obstacle generating system.

The problem is that with my current system there’s often a lot of empty space. I want it to be more packed.

My system is like this.

I have lots of possible obstacles to be placed, as shown here:

Each obstacle has an invisible barrier to make sure no other obstacles are too close to it.

The generator starts off all the way on the left of the map.

It picks a random obstacle and initially places it on the left of the map.

It then moves the obstacle all the way to the right of the obstacles already there, and repeats for the next obstacle until the map is completely generated from left to right.

The problem is that this creates a lot of empty space, because if there’s a short obstacle and then a tall obstacle, the tall obstacle would be shoved to the right of it, like this:

So, that means that ideally the generator would look through ALL the obstacles each time, see if any of them fit with the current obstacle in this row, and then keep going to the right.

Would this lag a lot because it needs to iterate through all the obstacles each time to see if anything fits with it? Is there a better way I should be going about this?

You can make a whitelist table for all of the obstacles that can go after each specifec obstacle. For example, obstacle a can only have obstacle b and obstacle c after it, while obstacle d can only have obstacle a and obstacle e after it.

If you’re worried about space being too tight, assign a width variable to each obstacle and offset it by that much from the last obstacle every time that obstacle appears.

1 Like

Thanks, I’ll try out the whitelist idea. But man it’s going to take a while to write.