hey, I’ve been working on a funny overused concept game for months before it was popularised and during those agonizing 6 months I STILL HAVE NOT figured out how to do TRUE random generation.
My goal here is to generate in chunks randomly and add the occasional props here and there randomly as well, the only problem is I have no idea how to do this.
I have a general idea of random/procedural generation, with set rooms and those rooms are positioned randomly to make a dungeon or maze.

How should I go about this? How should I use math.Random()? Is there an easy way to do this?

Any help is extremely appreciated, I really need this right now. Thank you in advance

EDIT: Please do let me know if this is not possible, and let me know if there is a way around it. Thank you

I don’t get how this is going to help me randomly generate chunks, all it is is telling me how to use functions I know how to use to some capacity, my question is how I would go about it; as in how would I randomly generate a completely random room? What parameters should I use (if any)? Is this even possible?

local seed1 = 8974239.462
local seed2 = 2484754.734
local scale1 = 0.001
local scale2 = 0.04
for x = -100, 100 do
for z = -100, 100 do
local noise = math.noise(x * scale1, seed1, z ^ scale1)
noise += math.noise(x * scale2 , seed2, z * scale2)
if noise > 0.1 then
local part = Instance.new("Part")
part.Position = vector3.new(x, 0, z)
part.Parent = game.Workspace
end
end
end

here you can see how I’m using math noise to generate random terrain and models around the terrain

and if you edit this place you can view the source code to my infinite terrain plugin that might help you

yes your terrain plugin does help a lot more than I thought it would, when I originally looked through the source code I thought I’d be able to modify it to do what I needed, but the problem is that my game ISN’T terrain, and I wasn’t sure how to go about making it parts of a set size but keeping the room size itself random… if that makes sense.

Sorry. It’s getting late and I for some reason got the impression you had chunks (like minecraft) and simply wanted to randomly distribute them.

Well, solution anyway is to use random numbers. If you are using a non-terrain world you may need to create “holders”, places where prebuilt items go. You can then use random numbers to decide which and if a prop should go there.

the original plan was actually to use set chunks so it’d be easier on me, but because I’m a bit too much of a perfectionist and I want to be the best at everything I do, I decided to make it truly random, but as I said in the post itself and in the reply to yours, I’m not even sure if truly random generation is possible to adjust to the way I want it

It is, but if you do true random it may be unplayable.

Random placements

Random parts (no models, no houses etc.)

Random colors

Random lighting

While this is sure to be an interesting sight to see. However, I’m not sure a truly random game would be too much fun, since there is no guarantee that you can move anywhere (random means gaps may occur).

what if you generate the game in grids and each square is lets says 50 x 50 studs and then you design lots of different 50x50 size rooms but some rooms dont have walls so there open to the room next to it you would get maybe something like this

local rooms = game.ReplicatedStorage.Rooms:GetChildren()
local roomSize = 50
local seed1 = 8974239.462
local seed2 = 2484754.734
local scale1 = 0.001
local scale2 = 0.04
for x = -100, 100 do
for z = -100, 100 do
local noise = (math.noise(x * scale1, seed1, z ^ scale1) + 0.5) / 2
noise += (math.noise(x * scale2 , seed2, z * scale2) + 0.5) / 2
noise = math.clamp(noise / 2, 0, 1)
noise = math.round(noise * (#rooms - 1) + 1)
local room = rooms[noise]
local clone = room:Clone()
clone:PivotTo(CFrame.new(x * roomSize, 0, z * roomSize)) -- you can also use noise to rotate the room
clone.Parent = game.Workspace
end
end

its a bit ugly but maybe this will help

its also possible to do it with random if the world is not infinite

local seed = 90802948
local random = Random.new(seed)
local rooms = game.ReplicatedStorage.Rooms:GetChildren()
local roomSize = 50
local mapSize = 8
for x = -mapSize, mapSize do
for z = -mapSize, mapSize do
local i = random:NextInteger(1, #rooms)
local room = rooms[i]
local clone = room:Clone()
clone:PivotTo(CFrame.new(x * roomSize, 0, z * roomSize))
clone.Parent = game.Workspace
end
end

and this is how you can do it with random but the seed will only generate the same map if the mapSize stays the same if you change the map size then the seed will generate a different map

Anyhow, that doesn’t really matter. What you can do are a few things, but making a defined grid-size will make everything so much easier.

One way to make it very simple for you is to make sure every room covers an entire grid slot (slim corridors may have walls filling out to the sides) and then randomly generate each new grid tile with random number generation.

Another way is to generate grid tiles based on neighboring tiles, for example tile X can not exist if tile Y is to the left of it.

alright, well how would I go about doing this? is there a specific method?
edit: for the generation, I know what you mean by the grid because I’ve done it before but I’m not sure how to make it actually possible