!RussianRoutette with ever-increasing odds the more times the command is used

The following russian roulette command is simply a 1 in 6 over and over:

$(eval Math.floor(Math.random() * 6) == 0 ? "You died" : "You survived")

I was wondering if this could be modified using the $(count) command somehow so that every time the command is called, the odds of losing increase incrementally.

Then you can use a companion command like !reload that resets the counting variable within the command after someone loses:

-a=!commands edit !russianroulette \-c=0

Hey @evalhelpquestion!

Yes you can use the $(count) variable, and you won’t even need the !reload command, just gotta use the remainder operator %:

$(eval parseInt('$(count)') % 6 === 0 ? 'You died' : 'You survived')

After testing the above, without the math.random element it seems that the command always just counts backwards so you always “win” on the first 5 command pushes and “lose” on the 6th. The fun of a command like this comes from the randomness that you could lose at any time.

Additionally, with the randomness re-implemented, it would be fun for there to be a message that tracks how many “chances” are left. An example return from Nightbot might read

You survived. 5 bullets remain.

If you really want the randomness, you can do it like this:

$(eval c = parseInt('$(count)'); Math.floor(Math.random() * (6 - c)) === 0 ? 'You died, please !reload' : `You survived, there are now ${c + 1} bullets in the magazine`)

The key is to make sure you get 0 when there are 6 bullets so you get a guaranteed loss, so when $(count) reaches 6, you multiply Math.random() by 0 because anything multiplied by 0 is equal to 0, therefore you need to multiply Math.random() by 6 minus $(count).

Correct me if I’m wrong, I believe that the current statistics for losing when pushing the above command break down as follows for the first 6 pushes:

1/6 = 16.67%
2/6 = 33%
3/6 = 50%
4/6 = 66%
5/6 = 83.33%
6/6 = 100%

If so, the desired statistics would be:

1/6 = 16.67%
1/5 = 20%
1/4 = 25%
1/3 = 33%
1/2 = 50%
1/1 = 100%

as though there were only one bullet and the trigger is being pulled over and over.

So instead of adding bullets every push, the desire is to subtract chambers (so people don’t lose as quickly).

Be clearer when you ask a question then, if you had those stats in mind when asking the question you should have shared them then.
You survived. 5 bullets remain.” — this kinda implies that you add bullets every time.

I enjoy writing code to solve other people’s “problems,” but don’t take it for granted. NightDev has no obligation to provide you with code for your commands, and so do I: I’m not a NightDev employee, I do this as a volunteer.
I have no problem revisiting my code if I misunderstood what you were looking for, but here you just didn’t explain what you were looking for properly, there’s a difference.
All I ask is that you have a clear idea of what you’re looking for before you ask for help, and that you put efforts in explaining it clearly and in details so I don’t have to guess and I can get straight to it, a bit like a scope statement. Yes, that’s work, but what am I doing for you if not work?
The least you can do to respect my time is to leave no room for guess work, code already requires (sometimes intense) creative work to translate the “problem” in logical steps the language used can understand and execute.

I wrote a lot of commands for you already, one could have hoped you learnt a thing or two, you’re pushing it.

Anyway, rant over, here’s the code you’re looking for:

$(eval c = parseInt('$(count)'); Math.floor(Math.random() * (6 - (c - 1))) === 0 ? 'You died, please !reload' : `You survived, a maximum of ${6 - c} pulls remain`)
1 Like

You’re right, I was unclear, and that rant was well deserved. The above is 100% what I envisioned, thanks for tolerating me!

1 Like

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