Math.randInt / Stop duplicate returns.
-
I have a randomizer button working. I notice that sometimes certain parameters dont change. Is that because Math.randInt is returning a duplicate number? Is there a formula to ensure that every integer returned is not the same as the last?
Some of my groups have smaller numbers like 12 items so I suspect the Math is just returning duplicates sometimes.
-
@Chazrox said in Math.randInt / Stop duplicate returns.:
Math.randInt is returning a duplicate number?
It's returning a random number, which might be the same as the previous number.
The usual way to handle this is to store the generated value in a variable, then generate random numbers in a while loop until you get one that isn't the same as the previous value.
It's also possible to do this without loops but the maths is a little more in depth. Here's an example of how to do it in Kontakt (KSP) for generating a non-repeating round robin - https://www.orangetreesamples.com/blog/scripting-nonrepeating-roundrobin
And here's me demonstrating how to use the principles of that KSP script in HISE
-
@d-healey Sweet! I'll watch this now. Hope you're having a great day brother! Thanks
-
C Chazrox marked this topic as a question
-
C Chazrox has marked this topic as solved