I have been through nearly every devforum article and YouTube video on making a game like Sol’s RNG. I have also been through the Sol’s RNG wiki. I still do not understand how the algorithm in Sol’s RNG works. I understand that the values and auras add up to more than one, so the “one in” values are not correct at all.
On the concept of luck, the Sol’s RNG wiki says that if your luck is greater than 2, then a common is impossible to roll (has 1 in 2 chance). It also says that if you have 2x luck then everything is twice a likely to be rolled. How would this work if there is a 1.25 luck. Wouldn’t everything be just a likely to be rolled?
Currently, I am using an algorithm similar to the one below, however I don’t understand how luck could be realistically implemented.
local totalChance = 0
for i, aura in ChancesList do
totalChance = totalChance + 1/aura["OneIn"]
end
local random = math.clamp(math.random(),0,1) -- between 0 and 1
local accumalatedChance = 0
for i, aura in ChancesList do
accumalatedChance = accumalatedChance + 1/aura["OneIn"]/totalChance
if random <= accumalatedChance then
return aura["Name"]
end
end
Please help me. I am very confused. Could someone tell me how the Sol’s RNG algorithm works if they know.
sols rng is an elaborate gambling game, when they say 1 in 2, they dont literally mean it
they mean out of all the possible chances its lets say a 50% chance of obtaining this one item.
to make what you are after you need a list of click bait names in your case your making a brain rot game so:
local Auras = {
["DumbAuraNameHere"] = 50,
["AnotherStupidName"] = 60,
["RandomName"] = 20,
}
local TotalAura = 0
for DumbAuraName, Aura in pairs(Auras) do
TotalAura = TotalAura + Aura
end
function GenerateRandomChance()
local RandomChance = math.random(1, TotalAura)
local Cumulative = 0
for DumbAuraName, Aura in pairs(Auras) do
Cumulative = Cumulative + Aura
if RandomChance <= Cumulative then
return DumbAuraName
end
end
end
print(GenerateRandomChance())
to put this extremely simple the higher the number the more likely it is to be selected
because the random chance is closer to the number
to have 1 in 2 you can set up your variables so they add up to 100% total then you can have your one value at 50 or 0.5 to represent 1 in 2
for the random chance factor to work theres an “total aura” variable right, to add luck into this algorithm what you can do is keep the total value variable same but change the “chance” value of each rarity like multiply them with luck.
lets say our luck is 2x and the “legendary aura” in the game has a 5 chance to be rolled
when you multiply its chance 5 with 2 you’ll have 2x more chance to get it and the luck factor for other common auras wouldn’t work
and also while doing the for in pairs loop to get the random aura its better that you have a array of auras going from the less chance to higher chance like the legendary aura must be at the beginning of the array for it to work correctly