Forums > MaxMSP

URN – Random number but without repeating?

January 19, 2007 | 4:01 pm

Not sure what you would call this situation but I’m trying to get the URN object to produce random numbers without repeating them but unfortunately is does repeat them after it as been cleared (after selecting all possible numbers).

How can I stop this from happening so it selects a different random number each time without repeating 2 in a row even when cleared?

Example below.

Many thanks,

Rhys

max v2;
#N vpatcher 583 280 1183 680;
#P button 117 99 15 0;
#P window setfont "Sans Serif" 9.;
#P number 117 186 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 139 104 33 196617 clear;
#P newex 117 133 34 196617 urn 3;
#P window linecount 2;
#P comment 157 186 100 196617 < ---- For each bang a different number?;
#P connect 4 0 1 0;
#P connect 2 0 1 0;
#P connect 1 0 3 0;
#P fasten 1 1 2 0 146 162 214 162 214 92 144 92;
#P pop;


January 19, 2007 | 4:16 pm

On 19 janv. 07, at 17:01, Rhys Perkins wrote:

>
> Not sure what you would call this situation but I’m trying to get
> the URN object to produce random numbers without repeating them but
> unfortunately is does repeat them after it as been cleared (after
> selecting all possible numbers).
>
> How can I stop this from happening so it selects a different random
> number each time without repeating 2 in a row even when cleared?

Have a look to the examples patches, there’s an abstraction called
urn-jb which avoid this repetition.

Best,
ej


January 19, 2007 | 4:24 pm

Perfect, thanks.


January 19, 2007 | 4:25 pm

?

if you bang that 3 times, it works. The third bang resets the counter
by sending clear, which removes any ‘saved’ state.

How do you plan on banging more than 3 times, with a range of 0 – 2,
without the object outputting duplicates?

if you bang it the 4th time, and it has outputted 0, 1 and 2.. what
should it do?

On Jan 19, 2007, at 11:01 AM, Rhys Perkins wrote:

>
> Not sure what you would call this situation but I’m trying to get
> the URN object to produce random numbers without repeating them but
> unfortunately is does repeat them after it as been cleared (after
> selecting all possible numbers).
>
> How can I stop this from happening so it selects a different random
> number each time without repeating 2 in a row even when cleared?
>
> Example below.
>
> Many thanks,
>
> Rhys
>
>
> max v2;
> #N vpatcher 583 280 1183 680;
> #P button 117 99 15 0;
> #P window setfont "Sans Serif" 9.;
> #P number 117 186 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P message 139 104 33 196617 clear;
> #P newex 117 133 34 196617 urn 3;
> #P window linecount 2;
> #P comment 157 186 100 196617 < ---- For each bang a different number?;
> #P connect 4 0 1 0;
> #P connect 2 0 1 0;
> #P connect 1 0 3 0;
> #P fasten 1 1 2 0 146 162 214 162 214 92 144 92;
> #P pop;

v a d e //

http://www.vade.info
abstrakt.vade.info


January 19, 2007 | 4:26 pm

Apologies. I read this too fast and missed

>How can I stop this from happening so it selects a different random
number each time without repeating 2 in a row even when cleared?

You could rig something with ‘change’ object.

On Jan 19, 2007, at 11:01 AM, Rhys Perkins wrote:

>
> Not sure what you would call this situation but I’m trying to get
> the URN object to produce random numbers without repeating them but
> unfortunately is does repeat them after it as been cleared (after
> selecting all possible numbers).
>
> How can I stop this from happening so it selects a different random
> number each time without repeating 2 in a row even when cleared?
>
> Example below.
>
> Many thanks,
>
> Rhys
>
>
> max v2;
> #N vpatcher 583 280 1183 680;
> #P button 117 99 15 0;
> #P window setfont "Sans Serif" 9.;
> #P number 117 186 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P message 139 104 33 196617 clear;
> #P newex 117 133 34 196617 urn 3;
> #P window linecount 2;
> #P comment 157 186 100 196617 < ---- For each bang a different number?;
> #P connect 4 0 1 0;
> #P connect 2 0 1 0;
> #P connect 1 0 3 0;
> #P fasten 1 1 2 0 146 162 214 162 214 92 144 92;
> #P pop;

v a d e //

http://www.vade.info
abstrakt.vade.info


January 19, 2007 | 4:47 pm


January 19, 2007 | 7:01 pm

karllheinz essl has a set of objects called RTC library (www.essl.at )
there an object called [random-norep] that creates a random number sequenze within a range specified by the argument and doesnt repeat any one number before its output all others. (serial number sequence)
have fun

WIll


Viewing 7 posts - 1 through 7 (of 7 total)