From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,a12fbc2d12506116 X-Google-Attributes: gid103376,public From: Pascal Obry Subject: Re: help with random number Date: 2000/11/13 Message-ID: #1/1 X-Deja-AN: 693009342 Content-Transfer-Encoding: 8bit Sender: obry@CLN46GB References: <5ltu0to0o3mt8c9liev26229n9mnhi0rvu@4ax.com> Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: newsadm@news.edf.fr X-Trace: clnews.edf.fr 974109951 22328 130.98.42.146 (13 Nov 2000 10:05:51 GMT) Organization: Electricite De France - http://www.edf.fr Mime-Version: 1.0 User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7 NNTP-Posting-Date: 13 Nov 2000 10:05:51 GMT Newsgroups: comp.lang.ada Date: 2000-11-13T10:05:51+00:00 List-Id: mountainman 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) 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"