TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: PETER DALTON
from: DAVID WILLIAMS
date: 1998-04-25 10:19:00
subject: using RND

-> the array (A%) holds zeros to start with. Generate a random number
-> (Y%) between 1 and 49 and check to see if that array element holds a
-> zero. If it does then poke a '1' in there, if it doesn't then find
-> another random number.
I don't dispute that a program *could* be written that would work as you
describe, and that it would produce satisfactory results - especially if
time is not a factor. But the whole purpose of my post was to
demonstrate that this kind of task can be carried out *without* ever
having to re-generate random numbers because the same ones have been
generated previously. Doing that kind of thing wastes time, sometimes a
great deal of time. And it is not at all necessary.
My program, as I posted it, produces six random integers, without any
possibility of repetition, by generating just six RNDs, no more, no
less. That's what I wanted to demonstrate.
With very minor modifications, the same routine can be used to simulate
shuffling a deck of 52 cards, extremely well (i.e. into an order that
has no correlation with the original one), by generating just 51 RNDs.
Try doing that by hunting and pecking!
                             dow
--- PCBoard (R) v15.3 (OS/2) 5
---------------
* Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.