Re: Progamming Challenge


[Prev][Next][Index][Thread]

Re: Progamming Challenge



At 2:50 PM -0100 4/22/98, Steve Muckle wrote:
>I am trying to make a program  that will simulate a deck of cards for a
>collectable card game.  I would  rather lay out a set of numbers at the
>beginning (each number representing a  particular card) than pick them on
>the fly.  What my problem is is that I  need to get a list (or a matrix,
>it doesn't matter) of numbers 1 through 60,  randomly assorted, BUT no
>number appearing more than once.

You might be sick of reading these but I figure that someone out there might
be interested in a different way. I made a card game and I ran into a similar
problem. So I made a list and accessed the elements with the following code
(note: initialize y as 51 before you want to run) Oh, this is for an 83 also.
       51->y
      ============
      LBL A
      randInt (0,y)->X
      L1(X)->A
      0->L1(X)
      sortd(L1)     <- this command sorts the list from high to low
      y-1->y
      GOTO A
This was a pretty simple way to solve my problem I thought. I didn't actually
do anything with the number (variable A) but you could do whatever you needed
to. It basically took all the numbers I accessed and changed them to zero,
then sorted them from high to low and made the next randomized pass only with
the non-zero numbers (which hadn't been used). So if anyone has any questions
or just comments I would appreciate it.
Adam
runor49@aol.com


Follow-Ups: