ssc/stdlib/random.sun
2016-02-01 05:44:29 -05:00

20 lines
422 B
Text

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