[Blindapple] Slightly OT - shuffling routine

Jayson Smith ratguy at bellsouth.net
Wed Nov 24 07:10:54 EST 2004


Um.  That's in C.  I'm looking for something in Basic.  Sorry about that!
Jayson.

----- Original Message -----
From: "Aaron Howell" <aaron at kitten.net.au>
To: "Blind Apple Discussions" <blindapple at jaybird.no-ip.info>
Sent: Wednesday, November 24, 2004 7:01 AM
Subject: Re: [Blindapple] Slightly OT - shuffling routine


> What you want it something like...
>
> shuffle(int deck[]){
> int i, j, k;
> for (i=0, i=sizeof(deck), i++){
> j=random()%sizeof(deck);
> k=deck[j];
> deck[j]=deck[i];
> deck[i]=k;
> }
> }
> I might be slightly out on the random line but that's the general formula
anyway (its been a long day, compile and test).
> Regards
> Aaron
> On Wed, Nov 24, 2004 at 04:26:21AM -0500, Jayson Smith wrote:
> > Hi,
> > I'm writing a game in Basic for the PC.  The game will require me to
> > randomize the order of arrays of strings.  The strings themselves will
be
> > contained in data statements in the program, and will be read into the
> > arrays.  I just need to shuffle them at the beginning of the game.  What
> > would be the easiest way to do this?  I want shuffled arrays rather than
> > just using a random element from the arrays each time as I don't want
> > repeats.  I plan to reshuffle whenever the last elements of the shuffled
> > arrays are used.
> > Jayson.
> >
> >
> > _______________________________________________
> > BlindApple mailing list
> > BlindApple at jaybird.no-ip.info
> > http://jaybird.no-ip.info/mailman/listinfo/blindapple
> _______________________________________________
> BlindApple mailing list
> BlindApple at jaybird.no-ip.info
> http://jaybird.no-ip.info/mailman/listinfo/blindapple
>




More information about the BlindApple mailing list