Random Numeric Output Based on Preset Odds

I would like to make a command that generates a “total kills” output based on a rate of 1/400.

To explain with a scenario:

The drop rate for a specific item is 1/400 kills. When the user does !blade, it rolls the odds of 1/400, but is not capped at 400. Meaning a user could ‘get the blade’ in 1 kill, or 2,000 kills.

I didn’t want to use this code

$(user) received their blade at $(customapi http://2g.be/twitch/randomnumber.php?=defstart=1&defend=1000&start=$(1)&end=$(2)) kc!

because it would roll equally from 1 to 1,000 instead of going off the odds of 1/400 chance.

Hiya, so what kind of range of numbers do you want, just change 1000 to that number. There is no set maximum, you’ll have to determine the range.

Also I would use the $(eval) approach:

!commands add !blade $(user) received their blade at $(eval Math.floor(Math.random()*1000 + 1)) kc!

Just change 1000 to the highest number of the range you want.

1 Like

Say I leave the command at 1000, would this not just roll at a 1/1000 chance? Meaning that you’re just as likely to get 500 as you are 50?

What I was sort of hoping for was a 1/400 chance roll, but uncapped so you could “go dry” for the blade and get it at 700 kills, or get lucky at get it in 10. This might be something that doesn’t work linearly with nightbot commands though.

Hey @relyonnoone!

So you want something that do a 1/1000 roll, but above 400 nothing happens?
What you’re trying to achieve is so unclear, can you try to re-word it, please?

Sure I can give it a shot;

So the scenario: An item has a static 1/400 drop chance (0.25%). The “chance” of getting the item in 1 kill count is 0.25%, whereas in 1,000 kill count is 91.82%. I would like the command to demonstrate this, if possible.

Meaning I could issue !blade and the output would roll 1-1,000, but the percent chance of getting the item at a smaller kill count (1) is lower than at a higher kill count (1,000).

My thoughts are that if I did a RNG from 1-1,000, each output has the same chance, so you’re just as likely to get the item in 1 kc as you are at 1,000 kc. Not exactly what I’m looking for.

Hopefully this is a little more clear!

In essence, I want to simulate getting a drop, which has a 1/400 chance, where you’re more likely to get the drop with a higher roll, and this roll is either a) uncapped or b) capped at something like 5,000 rolls.

1 Like

Thanks for clarifying! I’m not sure what the best way is to implement this, but I did find this topic:

I think thats what your looking for, however you will need to play around with the number to see if this is what you want.

In this example, I’m using min = 1, max = 700 and p = 0.5

!commands add !blade $(user) received their blade at $(eval Math.floor(1 + (700 - 1) * Math.pow(Math.random(), 0.5))) kc!
1 Like

Yep this works! Mathematical bias, who would’ve known that was the word I was looking for. I can tinker with this and get it working for sure. Thanks for the help!


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.