3 ms·
Interested as to why this method was picked over say doing "MSPlayed % 256"
by TomGullen 11y ago
Interested as to why this method was picked over say doing "MSPlayed % 256"
- deathanatos 11y agoAssuming by "MSPlayed" you mean "milliseconds played"; Another poster[1] links to a Doom wiki article[2], which explains, > The reason for the existence of two individual indexes is to maintain multiplayer synchronisation If you sync the PRNG's state at the beginning of the game, you can simply transmit the other client's input (such as keyboard/mouse): since each PRNG is in the same state on all the players' machines, you don't need to distribute over the network the results of PRNG choices: each client can just compute it locally. So long as all the code uses the PRNG's output stream for the same purposes, in the same order, everything is deterministic (while appearing to be random). Milliseconds played would also likely require some sort of OS/hardware interaction, to get to a timer. This is an add, an AND, and a memory lookup: likely significantly quicker (bear in mind the hardware Doom was created with/for). (Perhaps there are cycle counts, but I'm not sure that instruction was a thing yet? Though it was more reliable then…) Also see this post: https://news.ycombinator.com/item?id=9429889 https://news.ycombinator.com/item?id=9429889 [1]: https://news.ycombinator.com/item?id=9810073 https://news.ycombinator.com/item?id=9810073 [2]: http://doomwiki.org/wiki/Pseudorandom_number_generator http://doomwiki.org/wiki/Pseudorandom_number_generator
- TomGullen 11y agoThat makes sense, thanks!