Something basic as:
local chances = { -- %
["Common"] = 50,
["Rare"] = 30,
["Epic"] = 15,
["Legendary"] = 5,
}
Is easy to work with, as these numbers add up to 100 (%), which would make ‘50’ also 50% or 1/2.
Do all ‘big games’ use something like this, or is there a better system to accomodate many more additional chances (only listing three here)
local chances = {
["Cat"] = 50,
["Dog"] = 50,
["Super Epic Dragon"] = 0.5,
}
Would you manually change the odds of Cat and Dog to 49.75 respectively so the sum still equals 100?
Or is there a better way to do this, as manually trying to figure out what the introduction of a new item with a percentage means for a whole list of … maybe 20 other items seems like an unnecessary burden.
A solution that seemed right at first was to change the Random.new():NextNumber(0, 100)
to the sum of these odds (in this case 50 + 50 + 0.5 = NextNumber(0, 100.5)
)
But what does does is slightly skew the odds.
The 50% chance isn’t exactly 50 anymore, but rather ( 50 / 100.5 * 100 ) = 49.75124…
You might argue that yes, that’s pretty much 50% but when another item is introduced
local ItemChances = {
["Cat"] = 50,
["Dog"] = 50,
["Golden Monkey"] = 20,
["Super Epic Dragon"] = 0.5,
}
It be a Golden Monkey, the relative weight of these ( X on 120.5 ) is fine, but when trying to format them as a percentage it’s even more skewed (50% gets ~ 41,5%).
So what do you do?
-
Do you lie and display the odds as 50% of getting a Cat ?
-
Do you display a less pretty number and label the chance of a cat as 42% ?
-
Do you mention the odds as 1 in 2.5 ? (120.5/50=2,41)
Or is there a way to actually keep the odds at 50% by changing this total sum to an adjusted number of weight somehow?