5 ms·
I looked at the RNG in TempleOS out of curiosity. I assumed he was mixing in some noise sources that could be explained as some kind of universal communication
by throwaway7767 10y ago
I looked at the RNG in TempleOS out of curiosity. I assumed he was mixing in some noise sources that could be explained as some kind of universal communication subchannel from god. Here's the relevant code (in HolyC of course):
I32 RandI32()
{//Random I32. Xor with TimsStamp.
sys_rnd_seed.i32[0]=(1664525*sys_rnd_seed.i32[0]+1013904223)^GetTSC>>4;
return sys_rnd_seed.i32[0];
}
There are very similar RNG functions for signed and unsigned versions of 16, 32 and 64 bit ints. The GetTSC function just calls RDTSC, combines the two 32-bit halves in EAX and EDX and returns the recombined 64-bit TSC.
So the last returned value is used as part of the seed for the next one. The initial seed is set in kend.cpp:
sys_rnd_seed =93186752^GetTSC;
I have to admit, I was a bit disappointed that god would be quite so deterministic.
- grzm 10y agoRelevant xkcd: https://xkcd.com/221/ https://xkcd.com/221/
- vuanotinf 10y agoNo, not relevant. I wish someone would invent an ad blocker that instead blocked all gratuitous references to xkcd (i.e. all of them)
- dangsoocksdeek 10y agoNo, not relevant. I wish someone would invent an ad blocker that instead blocked all gratuitous references to xkcd (i.e. all of them)
- topkekz 10y agohe's now using Donald Knuth's LCG http://www.templeos.org/Wb/Kernel/KMathB.html http://www.templeos.org/Wb/Kernel/KMathB.html
- pjc50 10y agoGod does not throw dice. Apparently, he does use a linear congruential RNG.
- pawadu 10y agoNow how does free will come into this?