How to randomize the reels in slot machine command?

Asked Dec 26, 2023·5 replies·Last activity 2 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Below is an example of a simple slot machine command. The odds of green are 50% on the first reel, 33% on the second reel and 25% on the third reel. How do I edit this command to randomize the order of the reels so that sometimes the 50% reel is in the second spot or third spot etc.

[ $(eval var sayings = ['🟩', "🟥"]; sayings[Math.floor(Math.random() * sayings.length)];) | $(eval var sayings = ['🟩', '🟥', "🟥"]; sayings[Math.floor(Math.random() * sayings.length)];) | $(eval var sayings = ['🟩', '🟥', '🟥', "🟥"]; sayings[Math.floor(Math.random() * sayings.length)];) ]

5 replies

several ways to do it, but this is first that came to mind...

js
$(eval let a=[['🟩',"🟥"],['🟩','🟥',"🟥"],['🟩','🟥','🟥',"🟥"]],b=[],c=0,d=[];while(c<a.length){b[c]=a[c][Math.floor(Math.random()*a[c].length)];c++};c=0;while(c<a.length){x=Math.floor(Math.random()*b.length);if(b[x]!=0){d[c]=b[x];b[x]=0;c++}};d.join(` | `))

This is great, thank you tiwosslave! I've been trying to complicate it by setting variable odds on each reel individually for rare jackpots like 1 in 10,000,000, but haven't been able to accomplish it within 500 characters. The closest I was able to get was the code below which gives 1 in 10,000.

$(eval let a=[["⭐"],["⭐"],["$(eval satfact='$(urlfetch json https://paste.gg/p/anonymous/e919fa96dea64ccf956de88ff3756928)'.split(';'); satfact[Math.floor(Math.random() * satfact.length)];)"]],b=[],c=0,d=[];while(c<a.length){b[c]=a[c][Math.floor(Math.random()*a[c].length)];c++};c=0;while(c<a.length){x=Math.floor(Math.random()*b.length);if(b[x]!=0){d[c]=b[x];b[x]=0;c++}};d.join(` | `))

What I'm looking for is something like: the odds of a winning symbol on reel 1 is 1/10, reel 2 is 1/100 and reel 3 is 1/10000. If the random number generator selects the winning number for a reel, it takes from this array: ["⭐"], and if it doesn't hit the winning number for that reel, it will randomly select from this array: ['🍇', '🍈', '🍉', '🍊', '🍋', '🍌', '🍍', '🥭', '🍎', '🍏', '🍐', '🍑', '🍒', '🍓', '🫐', '🥝', '🍅', '🫒', "🥥"]

do u mean in addition to the current functionality?... or replace that with this new VERY RARE win version?

In addition. The reels have different rare probabilities to "hit" AND those reel positions are randomized every time.

oooo, fancy ^^ but i don't see any way to integrate that with the current selection process... would either have to rework the whole thing or have a secondary process that would override the first one

Didn't find your answer? The community is on Discord.

Ask on Discord