Better random numbers?

Hi, I have a custom command for Nightbot to generate a random number between 1 and 1071:
$(eval Math.floor((Math.random() * 1071) + 1))

It basically uses the JavaScript example on the Eval command in the documentation.

The problem is… it’s not that random. I’ve used the command about 80 times over 25 days of streaming and it has returned a number that has been picked before 7 times now… which is mathematically extremely unlikely. I’m not sure if this is JavaScript/Nightbot or something else going on… it doesn’t look like you can seed the JS either so I’m at a bit of a loss as to what I can do.

Any suggestions on what can be changed/improved for a better random number generator command to use for Nightbot?


An alternative option to the eval method is using the urlfetch method though both should be equally random but either way try this out


Thank you, I’ll give that a try… probably won’t know how random it is for another 25 days or so :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.