Temple of The Roguelike Forums
Development => Programming => Topic started by: Krice on March 26, 2010, 07:43:52 PM
-
I might as well ask for help to implement a routine which shoud scatter tiles around circular area and use a weight information to put more stuff on center area. Any ideas? My math skills are lousy, so I have hard time trying to figure this out.
-
Would you like the density to fall off as an inverse square? Or would you prefer Gaussian?
-
Would you like the density to fall off as an inverse square? Or would you prefer Gaussian?
You can decide that.
-
Would you like the density to fall off as an inverse square? Or would you prefer Gaussian?
You can decide that.
LOL
-
I like bell curves because they are easy
if you do this for both the x and the y you will end up with a nice circular distribution of items
R=radius
repeat 2 * R times
{
flip a coin
if heads
position+1
}
position - R/2
Although the possible positions is square, the probabilities is circular and so to your eyes it looks like a circle.
if you really wanted you could force it to be circular by looking at each point
dx means the difference between old x and new x
dy is the same for y
while(dx^2 +dy ^2 is > R^2)
use bresen's line to move it back toward the center
-
Sorry, I'm too dumb to make anything out of that pseudo code. Anyway, I decided to try flood fill and randomly skip seeds to create irregular shape (it would be always diamond shaped without that). I think it's working nicely and I could add that weigh part using the iteration count to determine the rough distance from the center. I'm only looking a way to create stuff like lakes and forests, or scattered rocks, anything like that.
-
That should work, the best algorithm is the one you understand perfectly.