mercredi 19 août 2015

Looking for a limited shuffle algorithm

I have a shuffling problem. There is lots of pages and discussions about shuffling a array of values completely, like a stack of cards.

What I need is a shuffle that will uniformly displace the array elements at most N places away from its starting position.

That is If N is 2 then element I will be shuffled at most to a position from I-2 to I+2 (within the bounds of the array).

This has proven to be tricky with some simple solutions resulting in a directional bias to the element movement, or by a non-uniform amount.




Aucun commentaire:

Enregistrer un commentaire