ASSS Questions - Random point generation Dr Brain - 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.
Mr Ekted - 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".
Muskrat - Thu Sep 09, 2004 1:05 am Post subject:
could you do this using a bitmap, such as from facts?