comp.lang.ada
 help / color / mirror / Atom feed
From: Pascal Obry <p.obry@der.edf.fr>
Subject: Re: help with random number
Date: 2000/11/13
Date: 2000-11-13T10:05:51+00:00	[thread overview]
Message-ID: <u7l681952.fsf@der.edf.fr> (raw)
In-Reply-To: 5ltu0to0o3mt8c9liev26229n9mnhi0rvu@4ax.com


mountainman <mountainman@123.net> writes:

> Hello to all of you smart people out there. I need some help. Im
> trying to create a random number generator that will only pull a
> specific number once and not repeat till told to do so. Im using an
> example I found on the net and it works great. I just dont know what
> to do to tell it not to pull the same number a second time untill i
> can reset it. Like a card game I need it to pull an Ace of Spades only
> once till the game is over.  Any help would be very appreciated.
> Thanks

What you want is a suite of Card, the cards on the deck are shuffled (so not
ordered), each one must be picked only once.

1)  Have a boolean associated with a card to tell if it has already been
    picked. Here you use the random generator to pick a card (not very
    efficient).

2)  Build an array of cards then swap 2 cards randomly many times, this will
    give you a shuffled cards deck (well an array of card :). Here you use the
    random generator to shuffle the cards.

3)  <put your own design here>

Pascal.

-- 

--|------------------------------------------------------------
--| Pascal Obry                               Team-Ada Member |
--|                                                           |
--| EDF-DER-IPN-SID- T T I                                    |
--|                       Intranet: http://cln46gb            |
--| Bureau N-023            e-mail: p.obry@der.edf.fr         |
--| 1 Av G�n�ral de Gaulle  voice : +33-1-47.65.50.91         |
--| 92141 Clamart CEDEX     fax   : +33-1-47.65.50.07         |
--| FRANCE                                                    |
--|------------------------------------------------------------
--|
--|         http://perso.wanadoo.fr/pascal.obry
--|
--|   "The best way to travel is by means of imagination"




  reply	other threads:[~2000-11-13  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-13  5:01 help with random number mountainman
2000-11-13  0:00 ` Pascal Obry [this message]
2000-11-13  0:00 ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox