Added RNG utility functions.

Intentionally did not import it in common.sun.
This commit is contained in:
arookas 2016-01-31 14:32:36 -05:00
parent 50348a9b47
commit ca8f59dea2

18
stdlib/random.sun Normal file
View file

@ -0,0 +1,18 @@
/* ================================================= *\
* random.sun
*
* ssc standard include utility
* 2016 arookas
\* ================================================= */
var __RAND_NEXT;
function srand(seed) {
__RAND_NEXT = seed;
}
function rand() {
// this is exactly the formula used in MSL (and, thus, SMS itself)
__RAND_NEXT = (__RAND_NEXT * 1103515245) + 12345;
return (__RAND_NEXT >> 16) & 0x7FFF;
}