2016-02-01 04:32:36 +09:00
|
|
|
/* ================================================= *\
|
|
|
|
* random.sun
|
|
|
|
*
|
|
|
|
* ssc standard include utility
|
|
|
|
* 2016 arookas
|
|
|
|
\* ================================================= */
|
|
|
|
|
2016-02-01 19:44:29 +09:00
|
|
|
import "ssc/common.sun";
|
|
|
|
|
2016-02-01 17:27:16 +09:00
|
|
|
var local next;
|
2016-02-01 04:32:36 +09:00
|
|
|
|
|
|
|
function srand(seed) {
|
2016-02-01 19:44:29 +09:00
|
|
|
next = int(seed);
|
2016-02-01 04:32:36 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function rand() {
|
|
|
|
// this is exactly the formula used in MSL (and, thus, SMS itself)
|
2016-02-01 17:27:16 +09:00
|
|
|
next = (next * 1103515245) + 12345;
|
|
|
|
return (next >> 16) & 0x7FFF;
|
2016-02-01 04:32:36 +09:00
|
|
|
}
|