local I=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")).Threader)local y=I.new(10,script.TerrainGeneratorWorker)local g=200 local n=2 local b=100 local G=5 local z=15 local a=(Random.new(n)):NextNumber()local m=15 local A={}for I=1,g,1 do for y=1,g,1 do table.insert(A,{x=I;z=y,seed=n;resolution=b,frequency=G;magnitude=z;waterHeight=a,extraHeigt=m})end end task.wait()local S=tick();(y:Dispatch(A)):andThen(function()local I=Instance.new("\080\097\114\116")I.Name="\087\097\116\101\114"I.Size=Vector3.new(g,1,g)I.Position=Vector3.new(g/2+.5,m+a*z,g/2+.5)I.Color=Color3.fromRGB(41,109,255)I.Transparency=.6 I.Anchored=true I.Parent=workspace print("\084\111\111\107",tick()-S,"\115\101\099\111\110\100\115 \116\111 \103\101\110\101\114\097\116\101 \116\101\114\114\097\105\110\046")end)
local Threader = require(game:GetService("ReplicatedStorage").Threader)

local TerrainGenerationThreader = Threader.new(10, script.TerrainGeneratorWorker)

local terrainSize = 200 -- terrainSize^2
local seed = 2
local resolution = 100
local frequency = 5
local magnitude = 15
local waterHeight = Random.new(seed):NextNumber()
local extraHeigt = 15

local terrainPositions = {}

for x = 1, terrainSize do
	for z = 1, terrainSize do
		table.insert(terrainPositions, {
			x = x,
			z = z,
			seed = seed,
			resolution = resolution,
			frequency = frequency,
			magnitude = magnitude,
			waterHeight = waterHeight,
			extraHeigt = extraHeigt,
		})
	end
end

task.wait()

local startTime = tick()

TerrainGenerationThreader:Dispatch(terrainPositions):andThen(function()
	local waterBlock = Instance.new("Part")
	waterBlock.Name = "Water"
	waterBlock.Size = Vector3.new(terrainSize, 1, terrainSize)
	waterBlock.Position =
		Vector3.new(terrainSize / 2 + 0.5, extraHeigt + waterHeight * magnitude, terrainSize / 2 + 0.5)
	waterBlock.Color = Color3.fromRGB(41, 109, 255)
	waterBlock.Transparency = 0.6
	waterBlock.Anchored = true
	waterBlock.Parent = workspace

	print("Took", tick() - startTime, "seconds to generate terrain.")
end)
