Jonny14
#1045598Tuesday, May 20, 2008 7:05 PM GMT

I tryied to use math.random stuff... nothing happend cuz I dont really know how to use it...
DingDong272
Top 100 Poster
#1046506Tuesday, May 20, 2008 8:36 PM GMT

Uh...What IS the Diamond Square Algorithm? I tried finding it but I didn't get it. Just fractal terrain generating.
FlashJoeW
Top 100 Poster
#1046618Tuesday, May 20, 2008 8:43 PM GMT

as a random note at the word "fractal" there's a programme called Tierazon, which allows you to create fractal drawings! now that's something you can go through life without even knowing...
commander79
#1046636Tuesday, May 20, 2008 8:44 PM GMT

Lol probally lots of people dont know that and they're life is probably over >:P
DingDong272
Top 100 Poster
#1046775Tuesday, May 20, 2008 8:55 PM GMT

XD I'll look into that. Probably not, but I'm saying I will anyway.
XlegoX
#1050468Wednesday, May 21, 2008 1:26 AM GMT

The diamond square algorthm IS s fractial It's just that it follows a random pattern, instead of a set one
nate2800
#1050609Wednesday, May 21, 2008 1:38 AM GMT

Diamond square algorithm does not follow a random pattern. The inside block heights are determined by the four outer corners which are set by hand ( of course you CAN set it with math.random() )
DingDong272
Top 100 Poster
#1050669Wednesday, May 21, 2008 1:42 AM GMT

Is it an actual algorithm? Like y = mx+b?
nate2800
#1051226Wednesday, May 21, 2008 2:24 AM GMT

Yes. Why do you think its called the "Diamond-square ALGORITHM"
XlegoX
#1051331Wednesday, May 21, 2008 2:40 AM GMT

=/ My diamond square algorithm keeps givving me erronious results, i'll have to start over
Dr01d3k4
#1071134Friday, May 23, 2008 5:36 PM GMT

I made my own Terrain Generator, only does 1 type of terrain but it's the best one I've made. First use my platform generator. Copy it when it is done, reset the place, paste it in, name it platforms, then name the other model that makes the platforms called something else, then delete the script from the full version. You should have a 10 x 10 grid. Then paste this script into a blank one, press play and watch. platforms = game.Workspace.Platforms editing = 2 function calcheight(part) if (editing == 2) then local prevnumb = platforms.Platform1 local height = math.random(-5, 5) part.Size = Vector3.new(10, prevnumb.Size.y + height, 10) elseif (editing > 2) and (editing < 11) then local prevnumb = editing - 1 local prevpart = platforms:findFirstChild("Platform"..prevnumb.."") local height = math.random(-5, 5) rise = height run = prevpart.Size.y d = height / prevpart.Size.y m = rise/run + (rise^(10/run))/rise if (m > 10) then local newm = rise/run + (rise^(10/run))/rise part.Size = Vector3.new(10, newm, 10) else if (m > 50) then m = m / 5 if (m > 50) then m = m / 5 if (m > 50) then m = m / 5 --print("NewHeight is "..newheight.."") part.Size = Vector3.new(10, m, 10) else part.Size = Vector3.new(10, m, 10) end else part.Size = Vector3.new(10, m, 10) end else part.Size = Vector3.new(10, m, 10) end part.Size = Vector3.new(10, m, 10) end --[[--print("NewHeight is "..newheight.."") if (newheight < 3) then print("Newheight is smaller then 3!") height = math.random(-2, 10) newheight = prevpart.Size.y + height part.Size = Vector3.new(10, newheight, 10) else part.Size = Vector3.new(10, newheight, 10) end --]]-- elseif (editing == 11) then local prevnumb = editing - 1 local prevpart = platforms:findFirstChild("Platform"..prevnumb.."") local tenprevnumb = editing - 10 local tenprevpart = platforms:findFirstChild("Platform"..tenprevnumb.."") local nineprevnumb = tenprevnumb + 1 local nineprevpart = platforms:findFirstChild("Platform"..nineprevnumb.."") local maxheight = 0 local minheight = 0 local height = (prevpart.Size.y + tenprevpart.Size.y + nineprevpart.Size.y + math.random(-5, 5)) / 3 part.Size = Vector3.new(10, height, 10) else local prevnumb = editing - 1 local prevpart = platforms:findFirstChild("Platform"..prevnumb.."") local tenprevnumb = editing - 10 local tenprevpart = platforms:findFirstChild("Platform"..tenprevnumb.."") local eleprevnumb = tenprevnumb - 1 local eleprevpart = platforms:findFirstChild("Platform"..eleprevnumb.."") local nineprevnumb = tenprevnumb + 1 local nineprevpart = platforms:findFirstChild("Platform"..nineprevnumb.."") local maxheight = 0 local minheight = 0 local height = (prevpart.Size.y + tenprevpart.Size.y + eleprevpart.Size.y + nineprevpart.Size.y + math.random(-5, 5)) / 4 part.Size = Vector3.new(10, height, 10) end end while true do wait() if (platforms.Platform1.Size == Vector3.new(10, 1, 10)) then platforms.Platform1.Size = Vector3.new(10, math.random(10,20), 10) wait() calcheight(platforms:findFirstChild("Platform"..editing.."")) editing = editing +1 if (editing == 101) then wait(20) editing = 2 end else wait() calcheight(platforms:findFirstChild("Platform"..editing.."")) editing = editing +1 if (editing == 101) then wait(20) editing = 2 end end end
Dr01d3k4
#1071447Friday, May 23, 2008 6:19 PM GMT

Is that script an algorithm? What it does is gets a random height for the first corner. Then continues up that line, getting the height for it from the part before it. Then when it has finished the first line, it goes through all the lines after it, basing the height from the part before it; part next to it and the parts diagonal to it. Then it divides that by 4 to get the height. Btw, I used some code from this thread to make it.
Dr01d3k4
#1071562Friday, May 23, 2008 6:37 PM GMT

Something is wrong with mine. If line 28 says "if (m 5) then" all the parts are really tall, apart from the first row of it. Can somebody tell me why/fix it
XlegoX
#1071585Friday, May 23, 2008 6:41 PM GMT

Looks inseresting, most of the time when you're talking about an algorthm, it referrs to a program that doesnt follow a set path, but runs off different things based on the environment The diamondsquare algorthm runs off the heights of the four cornerrs =P this is the way I did it function square(points, ammount) --if ammount is greater than cutoff, return --modify terrain within [ammount], of [points] new = {} --find the next four points near [point] and add them to [new] square(new, ammount/2) end square([middle point], [deviation])
BouyertheDestroyer
#1075560Saturday, May 24, 2008 12:00 AM GMT

are you asking how to use math.random()?
XlegoX
#1076656Saturday, May 24, 2008 1:49 AM GMT

who are you asking "are you asking "how to use math.random()""?
LuigiFan
#1078723Saturday, May 24, 2008 5:56 AM GMT

who are you asking "who are you asking "are you asking "how to use math.random()""?"? =P-LuigiFan-=P
Dr01d3k4
#1080052Saturday, May 24, 2008 12:20 PM GMT

I don't understand how to edit yours xLEGOx. Has anybody tried mine? I'm putting a colour changer into it now, then I will publish the outcomes. (Which are quite realistic, apart from 1 row whcih I don't know how to fix).
Dr01d3k4
#1092616Sunday, May 25, 2008 5:56 AM GMT

Bumps. I might publish my Terrain Generator to all models, or put it in a place.
dreaddraco2
#1093100Sunday, May 25, 2008 7:28 AM GMT

Dr01d3k4 make a Sword fight on the random terrain...
jak12321
#1093346Sunday, May 25, 2008 8:00 AM GMT

Just use CFrame
Dr01d3k4
#1109462Monday, May 26, 2008 3:37 PM GMT

print("BUMP")
gijsbel11
#23791757Tuesday, April 06, 2010 6:35 PM GMT

This is so handy for everyone here.
Penlu
#24065778Sunday, April 11, 2010 12:57 AM GMT

For the diamond-square algorithm, create a 3 by 3 matrix with the corners set. Then calculate the stuff for the middle squares. Insert new rows and columns and repeat using the neighbors of each zero-value place as the corners and stuff.
Malfact
#27579525Friday, June 18, 2010 3:40 AM GMT

?