I want to implement a random number generator which lets me set the maximum number I want but also lets me tweak the probabilities to make it harder to get bigger number.
Using this would allocate the same probabilities to any value in the range of 100.
Math.floor(Math.random()*100);
How can I make numbers get progressively harder to appear as the number gets closer to the limit (100)?
Square the result of
Math.random:You can adjust the curve by adjusting the exponent. Here’s a few graphs of different exponents:
If you’re going to use a non-integer exponent, you’ll need to use
Math.pow.