# Trying to understand the algorithm a game like Sol's RNG uses

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.

2 Likes

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

1 Like

Thank You, but how would luck be implemented into this? I’ve been having some struggle with figuring that out.

I’ve tried multiplying the random number by luck, but that is not realistic and often makes the highest rarity very common.

1 Like

Figure out a way to make higher rarities get a higher boost but lower rarities get a de-boost, maybe with a curve?

1 Like

I need it to work like sol’s rng. Things become twice as common with 2x luck and I’m having trouble understanding how that works.

2 Likes