How to get one random element from an array using mersenne twister in javascript?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to get one random element from an array using mersenne twister in javascript?



I inherited a gambling project, where mersenne twister is used as a random nunmber generator.



But I am not sure about the implementation of the same.



The library that is used gives random number [0,1>


[0,1>



Now, for the purpose of the app, it should give back one random number from an array of [0,1,2,...,n>


[0,1,2,...,n>



I was wondering, what is the easiest way to implement this, that is statistically correct. (that it passes bigcrush for example)



I believe that current implementation is very bad



https://gist.github.com/matejthetree/5c510babe767634b6c5189d9e482aca3



It is used to shuffle an array and then take one member from that array, instead of taking random [0,length> and choosing array[random]


[0,length>


array[random]









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS