On 04/10/10 16:06, [email protected] wrote:

That's a bad way to shuffle,

The same way that it's a really bad way to sort - maybe it could be classed as a bogobubblesort. I chose to do it that way for aesthetic purposes (a jumbled sequence gradually returns to order) rather than efficiency...

This might be relevant if you value correctness:
http://okmij.org/ftp/Haskell/perfect-shuffle.txt

as it can swap things back again and generally reduce the randomness, the way 
someone who is good at shufflng cards can put them all back the way they 
started while appearing to mix them up.

A better way is to start at the beginning of the array, swap the first item 
with one of the remaining items, then swap the second item, up to the end.

Martin

Claude wrote:
On 03/10/10 23:21, Andrew Faraday wrote:

Hey Guys
I've recently come across the .shuffle method in Ruby which randomly re-orders 
the content of an array. Does anyone know of a way to do this in Pd, that is, 
either change the order of notes within an array or output them in a random 
order (without repeating any part of it)?
Help would be appreciated
Andrew

You can pick pairs of indices at random and swap them with
tabread/tabwrite; repeat to shuffle more.

I used a similar technique to gradually sort an array (swap random
elements only if they are out of order):

https://code.goto10.org/svn/maximus/2007/clouds-are-made-of-water/
http://www.archive.org/details/ClaudiusMaximus_-_Clouds_Are_Made_Of_Water
(track 5)


Claude
--
http://claudiusmaximus.goto10.org

_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->  
http://lists.puredata.info/listinfo/pd-list
                                        


_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to