Author |
Message |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Thu Aug 26, 2004 3:28 pm Post subject: Random point generation |
 |
|
|
|
I have a need for a random point inside a non retangular region.
If the region were rectangular, a simple x+rand(width) would work.
My first thought was a loop that generates random points from 0,0 to 1023,1023 and checks it againts the region. Unfortunatly, this has the nasty side effect of totally hanging the server if the region has been misconfigured (easy to do).
Another thing to note is that these points will be used in warping, so checking near by walls would be nice but not essential. If it comes to it, I can make regions that aren't near any walls and don't enclose any walls.
At some point, I would like to see this function moved into mapdata.c. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Thu Aug 26, 2004 10:30 pm Post subject: |
 |
|
|
|
Pre-calculate how many tiles are in the region and gerate a random number in that range. The trick is then to efficiently map the number you generated to one of the tiles. Maybe a list of "tile rows". _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
Muskrat Server Help Squatter

Age:38 Joined: Aug 24 2004 Posts: 829 Location: Swamp Offline
|
Posted: Thu Sep 09, 2004 1:05 am Post subject: |
 |
|
|
|
could you do this using a bitmap, such as from facts? |
|
Back to top |
|
 |
|