??? 10/28/09 15:08 Read: times Msg Score: 0 +1 Informative -1 Overrated |
#170134 - Interesting anecdote regarding timers: Responding to: ???'s previous message |
Erik Malund said:
a very good way to get random numbers is to have a timer free running at highest possible speed and reading it when some external event (e.g. keypress, UART char received, ...) happens. This reminds me of a programming competition that one of the computer magazines I read held last year. The goal was to write a program that plays the classic arcade game "Asteroids", and the entry with the highest score wins. Now, there were many different approaches, but the really clever ones involved figuring out the state of the internal timer of the game, which is used for random number generation. Once the player program managed to do that (it only needed to observe a handful of events that depended on the RNG), it was able to predict the course of the game perfectly (where asteroids will appear at the start of the level, what speed and direction the fragments of a destroyed asteroid will have, whether it's safe to hyperjump and where the players ship will end up, etc). Such player programs would fire at objects only popped into existence when the shot arrived, and use the hyperspace button to get into optimal firing positions instead of just as an emergency measure. |