2 different random numbers…
hello,
I am trying to have on one action (one bang), two different number (no duplicates). I tried with random and urn, but i am not good at this, it seems.
Any help would be really appreciated. Thanks.
I’m not at my computer but if you bang into a trigger b b into each urn you’d get two random numbers on each bang. If you mean that you don’t want the two numbers to ever be the same you could check if they’re == and bang one again if they are I’d think.
Here are two solutions.
One using two [random], the second being retriggered as long as its output is the same as the previous [random]
And another using [urn], which very simply require to bang the object two times to get two different numbers, but also sending a clear message at the beginning (or end) of the process in order to reset the output numbers.
yes, that's it, I don’t want the two numbers to ever be the same. I think I have a solution with == thanks for your advice.
Below is my solution, in case it can help someone. I think it is a bit rough and clumsy, but I am far from being an expert in Max…
wow thanks TFL, this is much more clever than my stuff !!!
Thanks to both of you for help !
Your solution has some flaws:
When both randoms give the same number, only one of the two output numbers are updated
You can still get two same numbers as outputs in some circumstances (like if the right random outputs X Y and left random outputs X X)
The end result of your patch (and the behaviors described above) highly depend on the objects position in the patch, which can lead to different results if you position/organize your patch differently. For example, if you move the [==] all the way to the left, you won't get any output if the two random numbers are the same. This is all because of the objects order of execution, which is from right to left, bottom to top, which is why we use [trigger]/[t] to ensure the order of operations regardless of the objects positions.
I still believe the urn approach is the most straightforward. You can use [cycle] to get both numbers out of separate outlets if needed.
wow, that's it ! Thanks very much !!!
sorry to abuse : do you know if there is a way for an urn to generate a float number ? (between 0 and 1). I've tried with the "/" box, but it doesn't work (before or after the cycle).
i got it : "expr $f1 / 999". sorry for asking again…
When you seek two unique values from amongst a relatively small number of possibilities, TFL's urn-based solution is best. If you just want two unique random floats between 0. and 1., either of these two methods will give you a negligible (one in a million) chance of the two numbers being identical.
Thanks to you all. This help me finished a device I did begin a while ago, but never achieved :