I'm trying to get 3 alternate numbers in a list. Everything turns out fine, but what I try is that there is a chance that the same 3 can come out.
I plan to add this function to a discord.js command based on the number of votes a person has.
I currently do this.
let cosmetics = ["item1", "item2", "etc..."......];
const items = []
for (var i=0; i<3; i++)
items.push(cosmetics[Math.floor(Math.random() * cosmetics.length)])
This returns 3 items at random. But how do I control the probabilities that all 3 are the same? By the way ... the list of cosmetics has a quantity greater than 1500 items. That's why I'm interested in the probabilities (2%, 5%, 10%, 15%, 20%, 25%, 30%)
Aucun commentaire:
Enregistrer un commentaire