Skip to main content
gamedev.net
🔒 Locked

even distribution algorithms

Started by Structural 4 replies 3.8k views
Original Post
Structural
Structural
I'm looking for even distribution algorithm that can evenly distribute points within a 2D space untill that space has been filled up and the points are not closer than MIN and no further apart than MAX. For example for star system seeding. If you know the name of an algorithm or have a link or code even, everything is appreciated.
STOP THE PLANET!! I WANT TO GET OFF!!
smitty1276
smitty1276
You can use Monte Carlo sampling to get an even distribution. That will generate an even distribution, but won't make any guarantees about a min/max distance...

If you're wanting to generate a star system, my opinion is that you shouldn't have a min and a max... that ends up being *TOO* evenly distributed. If you're going to do that, you might as well divide your area/volume up into squares/cubes and randomly place 1 point in each.

I would just use a random distribution function (Monte Carlo) to random place some number of points. If you get a few right next to each other, so be it... that's how stars are too.
Lotus
Lotus
If you want it "even" then you only need to fix a horizontal distance (between MIN and MAX) and lay down the first row from left to right, then repeat that same row downwards. If you do not want to align them you can offset each row by a random amount, you can test if this amount is valid by testing the first point of the new row against the first two points of the previous raw, if they are good then all your points are good, otherwise modify the vertical distance.
Check out War to the Core the world domination space MOBA-RTS hybrid.
Join us on Discord.
Into sci-fi novels? Then check out Spectral Legends.
smitty1276
smitty1276
Quote:
Original post by phresnel
... and combining smitty1276's and ToohrVyk's replies leads to Quasi Monte Carlo Sampling :)

Ah, looking at that link, the term that was eluding me is "stratification". :-)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.