Clean up pseudorandom() a bit.

This commit is contained in:
Marco Cawthorne 2021-09-02 09:47:48 +02:00
parent 527318bd65
commit 4a2cde56cc
Signed by: eukara
GPG Key ID: C196CD8BA993248A
1 changed files with 6 additions and 7 deletions

View File

@ -113,15 +113,14 @@ noref int input_sequence;
float
pseudorandom()
{
float a = (float)input_sequence % 5;
float b = (float)input_sequence % 8;
float c = (float)input_sequence % 4;
float d = (float)input_sequence % 13;
float f = (float)input_sequence % 70;
print(sprintf("random %f\n", (a+b+c+d+f) / 100.0f));
float seed = (float)input_sequence % 5;
seed += (float)input_sequence % 8;
seed += (float)input_sequence % 4;
seed += (float)input_sequence % 13;
seed += (float)input_sequence % 70;
/* like the engine its random(), never return 0, never return 1 */
return bound(0.01, (a+b+c+d+f) / 100.0f, 0.99f);
return bound(0.01, (seed) / 100.0f, 0.99f);
}
__wrap void