Talk About Network

Google





Programming > Assembly Language > Re: I pee in th...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 17 of 20 Topic 5075 of 5194
Post > Topic >>

Re: I pee in the open

by Robert Redelmeier <redelm@[EMAIL PROTECTED] > Jul 22, 2008 at 11:14 PM

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
>
 




 20 Posts in Topic:
Re: I pee in the open
"Alexei A. Frounze&q  2008-07-14 01:15:57 
Re: I pee in the open
"Rod Pemberton"  2008-07-14 05:39:09 
Re: I pee in the open
"Wolfgang Kern"  2008-07-14 13:18:06 
Re: I pee in the open
"H. Peter Anvin"  2008-07-14 13:03:34 
Re: I pee in the open
"Wolfgang Kern"  2008-07-14 22:50:38 
Re: I pee in the open
Phil Carmody <thefatph  2008-07-15 03:25:24 
Re: I pee in the open
"Rod Pemberton"  2008-07-15 05:01:34 
Re: I pee in the open
"Wolfgang Kern"  2008-07-15 11:43:35 
Re: I pee in the open
"Rod Pemberton"  2008-07-15 08:39:19 
Re: I pee in the open
"Wolfgang Kern"  2008-07-15 18:56:35 
Re: I pee in the open
"H. Peter Anvin"  2008-07-18 14:07:16 
Re: I pee in the open
"Rod Pemberton"  2008-07-19 04:13:29 
Re: I pee in the open
"H. Peter Anvin"  2008-07-19 19:18:14 
Re: I pee in the open
"Rod Pemberton"  2008-07-20 14:45:57 
Re: I pee in the open
Robert Redelmeier <red  2008-07-21 03:01:16 
Re: I pee in the open
"Rod Pemberton"  2008-07-21 04:18:57 
Re: I pee in the open
Robert Redelmeier <red  2008-07-22 23:14:35 
Re: I pee in the open
"Rod Pemberton"  2008-07-22 22:31:27 
Re: I pee in the open
Robert Redelmeier <red  2008-07-23 18:21:47 
Re: I pee in the open
"Rod Pemberton"  2008-07-23 18:41:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 17:48:10 PST 2009.