Re: [Algorithms] semi-random numbers
Brought to you by:
vexxed72
From: <phi...@pl...> - 2003-01-28 23:16:31
|
Brian: > For example, a spawn point may generate a new powerup "about every 30 seconds". But you don't want it to be timed to exactly 30 seconds, since it becomes too predictable. So you set it up so that at 20 seconds there's a 5% chance it occurs, by 30 seconds there's at least a 60% chance it occurs, and at 45 seconds it will definitely occur. I believe Everquest sets a timer to the next respawn, rather than checking for respawn every frame. So each time an object spawns, or dies, or fulfills whatever criteria recquired to trigger a possible respawn, you initialise a timer to, in your case, somewhere between 20 and 45, with whatever distribution you want. Then, when the timer hits zero, respawn. Or is that what you were saying anyway? It'd be interesting to write a version of say, Tetris, that used this sort of mechanism to generate pieces, rather than just picking them at random. I'm sure you could relatively easily come up with a system that gauranteed you never went more than 20 pieces without one of those long thin ones dropping... Cheers, Phil |