> Then assign each a random number e.g.
> [0.2314-card(1,h), 0.6341-card(2,h), 0.3101-card(3,h), ... ]
> Keysort that list and your cards are shuffled.
The Ken J.'s algorithm is amusing but has an n*log(n) complexity
(because sorting). Mine has a linear complexity and I can claim a
better percentage for the share.
This is getting rather off-lisp, but I would still like to note that
using a random number generator to reorder the cards might not be a
very good way of modeling card shuffling. I would suggest doing
something like
1) pick a random position in the deck, favoring middle
positions over extremes
2) merge the parts by randomly picking a card at a time from
either of the halves
3) repeat the above
--
Pertti Kellom\"aki (TeX format) # These opinions are mine,
Tampere Univ. of TeXnology # ALL MINE !
Software Systems Lab # (but go ahead and use them, if you like)
From: Carl M Kadie
Subject: Re: WANTED: Card shuffling algorithm
Date:
Message-ID: <CLoGu7.JM6@cs.uiuc.edu>
··@kaulushaikara.cs.tut.fi (Kellom{ki Pertti) writes:
>using a random number generator to reorder the cards might not be a
>very good way of modeling card shuffling. I would suggest doing
>something like
>
> 1) pick a random position in the deck, favoring middle
> positions over extremes
> 2) merge the parts by randomly picking a card at a time from
^^^^^^^
> either of the halves
> 3) repeat the above
I once did some experiments on how I shuffle cards. With ~50%
probability only a single card falls. With ~25% probability two cards
fall together. With 12.5% probability three cards fall together. Etc.
The experiment is easy to do, just cut the deck, but before you merge
the two halves together, flip one half over (back to front). Merge.
Now count the number of each size clump.
- Carl
--
Carl Kadie -- I do not represent any organization; this is just me.
= ·····@cs.uiuc.edu =