Another way is to generate a random number, save this number and use it
as a seed the next time the patch gets opened. This way you will always
have a fresh seed.

Two examples attached, random.pd saves the seed within the patch,
random2.pd saves the seed in a text file. random2.pd throws an error the
first time, if the text file is not present.

best, ingo


On 05/30/2018 04:41 PM, Claude Heiland-Allen wrote:
> On 30/05/18 15:17, Jean-Marie Adrien wrote:
>> Hi everyone,
>> trying to open a patch with a different text on screen each time random.
>> Used random object as always since 20 years with a loadbang.
>> Discovered that this loadbang/random seems to generate always the same
>> result on opening
>> :)
> It's a feature.  But not having non-determinism is a bit awkward sometimes.
> 
>> What is the correct way to get a random digit on patch load within say
>> 30 choices ?
> 
> You can generate a random number before starting Pd and -send it to your
> patch on load.
> (requires knowledge of shell/cmd scripting)
> (this is the approach I took in my 'dynamo' project:
> https://code.mathr.co.uk/dynamo )
> 
> You can try to read raw binary data from /dev/urandom, perhaps with
> [soundfiler] or [readsf~]
> (requires an OS with this device, and I have not tested it)
> 
> You could try reading from [adc~] or analogue sensor pins
> (requires some unpredictable signal input, possibly special hardware)
> 
> You could try [delay] with [realtime]
> (you might get one or two bits of randomness each time)
> 
> You could try an external
> (maybe some function of calendar time will look random enough? I think
> zexy has date support)
> 
> 
> Claude
#N canvas 600 329 313 321 12;
#X obj 40 46 loadbang;
#X msg 152 115 set seed \$1;
#X msg 86 92 seed 168;
#X obj 134 46 namecanvas \$0-this;
#X obj 40 253 print;
#X msg 126 161 menusave;
#X obj 126 184 s \$0-this;
#X obj 40 230 t f f;
#X obj 40 207 random 100;
#X obj 63 115 random 1000;
#X obj 63 138 t f b f;
#X msg 63 161 seed \$1;
#X obj 40 69 t b b b;
#X connect 0 0 12 0;
#X connect 1 0 2 0;
#X connect 2 0 9 0;
#X connect 5 0 6 0;
#X connect 7 0 4 0;
#X connect 8 0 7 0;
#X connect 9 0 10 0;
#X connect 10 0 11 0;
#X connect 10 1 5 0;
#X connect 10 2 1 0;
#X connect 11 0 8 0;
#X connect 12 0 8 0;
#X connect 12 1 9 0;
#X connect 12 2 2 0;
#N canvas 600 329 313 451 12;
#X obj 47 39 loadbang;
#X obj 139 39 table \$0-seed 1;
#X obj 70 131 tabread \$0-seed;
#X msg 70 108 0;
#X obj 70 200 random 10000;
#X msg 102 177 seed \$1;
#X obj 70 154 t b f;
#X obj 116 246 tabwrite \$0-seed;
#X obj 70 223 t f b f;
#X msg 104 85 read seed.txt;
#X obj 104 108 s \$0-seed;
#X obj 93 292 s \$0-seed;
#X msg 93 269 write seed.txt;
#X msg 70 315 seed \$1;
#X obj 47 62 t b b b;
#X obj 47 361 print;
#X obj 47 338 random 100;
#X connect 0 0 14 0;
#X connect 2 0 6 0;
#X connect 3 0 2 0;
#X connect 4 0 8 0;
#X connect 5 0 4 0;
#X connect 6 0 4 0;
#X connect 6 1 5 0;
#X connect 8 0 13 0;
#X connect 8 1 12 0;
#X connect 8 2 7 0;
#X connect 9 0 10 0;
#X connect 12 0 11 0;
#X connect 13 0 16 0;
#X connect 14 0 16 0;
#X connect 14 1 3 0;
#X connect 14 2 9 0;
#X connect 16 0 15 0;

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list

Reply via email to