Author Topic: Need for weighed scattering routine  (Read 18105 times)

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Need for weighed scattering routine
« 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.

Hi

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 154
  • Karma: +0/-0
    • View Profile
    • Email
Re: Need for weighed scattering routine
« Reply #1 on: March 26, 2010, 07:59:38 PM »
Would you like the density to fall off as an inverse square?  Or would you prefer Gaussian?

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Need for weighed scattering routine
« Reply #2 on: March 26, 2010, 09:35:54 PM »
Would you like the density to fall off as an inverse square?  Or would you prefer Gaussian?

You can decide that.

corremn

  • Rogueliker
  • ***
  • Posts: 700
  • Karma: +0/-0
  • SewerJack Extraordinaire
    • View Profile
    • Demise RogueLike Games
Re: Need for weighed scattering routine
« Reply #3 on: March 27, 2010, 01:09:46 AM »
Would you like the density to fall off as an inverse square?  Or would you prefer Gaussian?

You can decide that.
LOL
corremn's Roguelikes. To admit defeat is to blaspheme against the Emperor.  Warhammer 40000 the Roguelike

Hi

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 154
  • Karma: +0/-0
    • View Profile
    • Email
Re: Need for weighed scattering routine
« Reply #4 on: March 27, 2010, 03:11:25 AM »
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
« Last Edit: March 27, 2010, 03:20:08 AM by Hi »

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Need for weighed scattering routine
« Reply #5 on: March 27, 2010, 10:47:12 AM »
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.

Hi

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 154
  • Karma: +0/-0
    • View Profile
    • Email
Re: Need for weighed scattering routine
« Reply #6 on: March 27, 2010, 05:22:36 PM »
That should work, the best algorithm is the one you understand perfectly.