Rod Pemberton <do_not_have@[EMAIL PROTECTED]
> wrote in part:
> Why draw randomly? You can properly simulate a hand shuffled deck of
cards
> from an initially ordered deck in a few lines of C code: [snipped below]
Very cute, a simulation of human cut'n'flutter shuffling.
Hwever, the results are far from random. It looks like the
deepest the top card can move is the 6 last card in the
deck. It is pseudo-random.
-- Robert
> void shuffle_cards(void)
> {
> int pull[52];
> int cut,flutter;
> int i,j,k,s,t;
>
> for(i=0;i<52;i++)
> pull[i]=deck[i];
> cut=26-(rand()>>3)%((1+(rand()>>3)%(7+1))+1);
> flutter=1+(rand()>>3)%((1+(rand()>>3)%(4+1))+1);
> for(i=0,j=0,k=0,s=1,t=0;i<52;s++)
> {
> if(t)
> {
> if(j<cut)
> deck[i++]=pull[j++];
> }
> else
> {
> if(k<(52-cut))
> deck[i++]=pull[cut+k++];
> }
> if(s==flutter)
> {
> t=!t;
> s=0;
> flutter=1+(rand()>>3)%((1+(rand()>>3)%(4+1))+1);
> }
> }
>
> }
>
> int main(void)
> {
> int i;
>
> for(i=0;i<52;i++)
> deck[i]=i;
> srand(time(0));
>
> shuffle_cards();
> shuffle_cards();
> shuffle_cards();
> display_cards();
>
> return(0);
> }
>
>
> RP
>


|