3 ms·
It annoyed me when I heard that some guys slapped their name on that algorithm (having "invented" it independently for a game). It seems like another of those n
by Tichy 17y ago
It annoyed me when I heard that some guys slapped their name on that algorithm (having "invented" it independently for a game). It seems like another of those not patent worthy obvious things. Why is it obvious: because you should realise that there is a random number generator in your programming language. Therefore shuffling is silly. You want to assign the cards to slots determined by the random number generator directly. From there on it is pretty straightforward. </brag>
- scott_s 17y agohttp://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
- Tichy 17y agoYes? That is what I described - I left the swapping part as an exercise to the reader (since it is already described in the article submission). It seems to be the only logical way (I have not tried to think of another way, though - but none has been mentioned yet on HN, either).
- scott_s 17y agoThey didn't "slap their name on it." Other people refer to it as their algorithm because they came up with it first. It's obvious to you that someone would want an algorithm for a random shuffle of a sequence. It wasn't obvious at the time.
- Tichy 17y agoWhat I was trying to say is that the algorithm is the obvious consequence of wanting to assign a sequence to random places in an array. I wanted it because I was programming a game. I think the same must have happened to many people. Anyway, no biggie - of course the world doesn't end because now the algorithm has a name.
- scott_s 17y agoAnd what you're missing is that they realized people might want to randomly shuffle a sequence before there was obvious applications for it.
- Tichy 17y agoI guess I did not describe it fully enough - to assign randomly, you end up noticing that you don't want to waste time checking for slots you already assigned. So the logical solution is to shrink the array by swapping out the randomly chosen index - basically the "good knuth". If you don't have an uninterrupted streak of cells to assign, you end up doing wasteful checks. Can't think of another way, off the top of my head.