Hi!

I’m using the random(value) to get random integers with a scale of 20. Is there a way to make sure that every value in the range got used until a “new” cycle starts? I’m trying to avoid repeating numbers…

Thanks!

Hi!

I’m using the random(value) to get random integers with a scale of 20. Is there a way to make sure that every value in the range got used until a “new” cycle starts? I’m trying to avoid repeating numbers…

Thanks!

That is called shuffle and is a non trivial problem, the Random node cannot do that.

I think there is a module for that somewhere.

If you can’t find it use a RandomSpread with count 20 and a Sort node to get the former index. Then a Counter to get one index after the other… For the next cycle (Counter overflow) you need to set another Random Seed at the RandomSpread…

There is one problem with this approach, although a very little problem: You risk that the last value of one randomized list is the same as the first value in the next list. it will not happen very often, but it will happen from time to time.

I have given that problem some thought and I can’t find any simple solution for it. is there a way to avoid it while keeping the patch simple?

And actually if you say that a given number should not be selected again until after a set number of other numbers have been chosen so we also avoid having the last number of one list being the same as the second number of the second list and other such combinations.

Thinking about it, it is not too complicated with some framedelays and sift. Here you might have two numbers coming up in a shorter interval than the max number of numbers you are choosing between, but you are guarantied that the same number will not repeat until at least a minimum of other numbers you decide have come by. this quick patch is not spreadable… next version.

RandomNonRepeat.v4p (12.2 kB)

Well, it seems this is more complex than I thought. I think I’ll go with the list version for now. Thank you!