let's say for example I want to get a random number between 1 and 360 I did it this way Math.floor(Math.random() * (360 -1+1 )+1)
Now I want to create a probability out of 100
- if the number was between 1 and 30 the probability will be 0.05,
- if the number was between 30 and 60 the probability will be 0.05,
- if the number was between 60 and 90 the probability will be 0.10,
- if the number was between 90 and 120 the probability will be 5,
- if the number was between 120 and 150 the probability will be 5,
- if the number was between 150 and 180 the probability will be 5,
- if the number was between 180 and 210 the probability will be 5,
- if the number was between 210 and 240 the probability will be 13,
- if the number was between 240 and 270 the probability will be 16,
- if the number was between 270 and 300 the probability will be 16,
- if the number was between 300 and 330 the probability will be 16.8,
- if the number was between 330 and 360 the probability will be 18
(0.05+0.05+0.10+5+5+5+5+13+16+16+16.8+18=100)
How can I achieve this
Aucun commentaire:
Enregistrer un commentaire