local MapSize = 64
math.randomseed(tick())
local Seed = math.random(-1000000000, 1000000000) % math.random(-1000000000, 1000000000)
math.randomseed(Seed)
local Seed = math.random(-1000000000, 1000000000) % math.random(-1000000000, 1000000000)
local NoiseScale = 10
local Amp = 20
local BlockSize = 2
local MaxDensity = -14 -- Must be a Number between -10, 10
-- -969535336
for x = 0, MapSize do
for z = 0, MapSize do
for y = 0, MapSize do
local Xnoise = math.noise(y / NoiseScale, z / NoiseScale, Seed) * Amp
local Ynoise = math.noise(x / NoiseScale, z / NoiseScale, Seed) * Amp
local Znoise = math.noise(x / NoiseScale, y / NoiseScale, Seed) * Amp
local Density = Xnoise + Ynoise + Znoise
if Density < MaxDensity then
local Part = Instance.new("Part", workspace)
Part.Anchored = true
Part.Reflectance = 1
Part.Size = Vector3.new(BlockSize, BlockSize, BlockSize)
Part.CFrame = CFrame.new(x*BlockSize, y*BlockSize, z*BlockSize)
end
end
end
wait()
end
One thing you can do is go to line 20 (Where the local density variable is), then you add + y to the equation. This will give you a result similar to this:
There is no need to pass arguments to your math.random because it will generate a random number with lots of decimal points anyway. Just multiply it by a constant if you feel results aren’t random enough. You can use ticks for seeds too.
Also, consider using the new class Random. Apparently it is more efficient, more random, and a better interface.
What is the purpose of the wait() at the end of the first for loop? This shouldn’t be in a game because it would just slow down the generation. If it’s to prevent studio crashing or to visualise it then I get it.
I’d also suggest you move to camel case for variables because it increases readability and conforms with standards but I suppose that’s just a personal preference. I used to use Pascal case for everything for about 5 years then suddenly switched a few years ago. Was 100% worth it.
Apart from that the generation algorithm looks very good.
Do you mean just multiply the random number by a number?
It is quite obvious lol. To prevent crashing.
What is camel case? I have been using local variables the whole time I have been scripting on roblox.
Yes the algorithm is logical. We generate enough 2D noise maps with the right arguments every time then we combine them in the “Density” variable by adding them.