random is broken
clankill3r opened this issue · 4 comments
The values produced by random are like 1000 times lower then they should be.
For example, this are the numbers between 4 and 8:
4.00001660175622
4.00000739656389
4.00002503395081
4.00005162227899
4.00000867806375
4.00003036111593
4.00005471613258
4.00003544334322
4.00005575269461
4.00001819804311
Hi @clankill3r Thanks for the bug report. Are you referring to the v2 version or are you using v1?
This is the code we should be looking at
Lines 689 to 709 in cb1e7c6
For comparison here is the code from p5js https://github.com/processing/p5.js/blob/c3f4121619174db5eaaf09b8ca51c93d530caa27/src/math/random.js#L86-L149
Can you provide the code you used to create these values? Or even better write a failing test based on the v2 branch?
Ok, I did some tests. As soon as you use a randomSeed it breaks.
#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basiljs/bundle2/basil.js";
function draw() {
clear(page());
randomSeed(43535);
txt = "";
for (var i = 0; i < 25; i++) {
txt += random(4, 8) + "\n";
}
textSize(100);
text(txt, 50, 50, 4096, 4096);
}
Thank you @clankill3r We will have a look ASAP.
Heyhey - just ran into this with a student = randomSeed()
and noiseSeed()
both seem to be broken, as they are producing the same results regardless of usage... I'll also have a look soon, unless something was found last year?