Jonny14Join Date: 2007-12-15 Post Count: 122 |
I tryied to use math.random stuff... nothing happend cuz I dont really know how to use it... |
|
DingDong272Top 100 PosterJoin Date: 2007-12-08 Post Count: 9860 |
Uh...What IS the Diamond Square Algorithm? I tried finding it but I didn't get it. Just fractal terrain generating. |
|
FlashJoeWTop 100 PosterJoin Date: 2007-12-24 Post Count: 4886 |
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... |
|
|
Lol probally lots of people dont know that and they're life is probably over >:P |
|
DingDong272Top 100 PosterJoin Date: 2007-12-08 Post Count: 9860 |
XD
I'll look into that.
Probably not, but I'm saying I will anyway. |
|
XlegoXJoin Date: 2008-06-16 Post Count: 14955 |
The diamond square algorthm IS s fractial
It's just that it follows a random pattern, instead of a set one |
|
nate2800Join Date: 2007-08-16 Post Count: 828 |
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() )
|
|
DingDong272Top 100 PosterJoin Date: 2007-12-08 Post Count: 9860 |
Is it an actual algorithm? Like y = mx+b? |
|
nate2800Join Date: 2007-08-16 Post Count: 828 |
Yes. Why do you think its called the "Diamond-square ALGORITHM" |
|
XlegoXJoin Date: 2008-06-16 Post Count: 14955 |
=/
My diamond square algorithm keeps givving me erronious results, i'll have to start over |
|
Dr01d3k4Join Date: 2007-10-11 Post Count: 17916 |
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 |
|
Dr01d3k4Join Date: 2007-10-11 Post Count: 17916 |
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. |
|
Dr01d3k4Join Date: 2007-10-11 Post Count: 17916 |
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 |
|
XlegoXJoin Date: 2008-06-16 Post Count: 14955 |
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])
|
|
|
are you asking how to use math.random()? |
|
XlegoXJoin Date: 2008-06-16 Post Count: 14955 |
who are you asking "are you asking "how to use math.random()""? |
|
LuigiFanJoin Date: 2007-06-18 Post Count: 4143 |
who are you asking "who are you asking "are you asking "how to use math.random()""?"?
=P-LuigiFan-=P |
|
Dr01d3k4Join Date: 2007-10-11 Post Count: 17916 |
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). |
|
Dr01d3k4Join Date: 2007-10-11 Post Count: 17916 |
Bumps. I might publish my Terrain Generator to all models, or put it in a place. |
|
|
Dr01d3k4 make a Sword fight on the random terrain... |
|
jak12321Join Date: 2007-12-12 Post Count: 2814 |
Just use CFrame |
|
Dr01d3k4Join Date: 2007-10-11 Post Count: 17916 |
print("BUMP") |
|
gijsbel11Join Date: 2009-02-07 Post Count: 4223 |
This is so handy for everyone here. |
|
PenluJoin Date: 2008-01-12 Post Count: 709 |
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. |
|
MalfactJoin Date: 2007-11-02 Post Count: 2767 |
? |
|