TIP: Click on subject to list as thread! ANSI
echo: commo
to: CHUCK SEYBOLDT (Rcvd)
from: CARL MORRIS
date: 1995-05-23 16:05:00
subject: Re: Random Number Generator

CS>         Feel free to crib from CS-MAC anytime, all I ask is that you
CS> give me credit if you get stuff out of there.
A better one here yet:
Random number generation.  Variable _RND_TAB is permanent, do not use it!
Enter RANDOM with _r_min set to minimum value and _r_max set to the maximum
value.  Return is in _r_rnd.      Version .99!
{:RANDOM}               you call this, it builds your number}
        {setv _r_rnd}
{:ran_1}{call rnddig} {subs _r_tmp,-1,1,%_rnd_tab}
        {setv _r_rnd,%_r_rnd%%_r_tmp} {mult _r_rnd,1}
        {comp _r_rnd,%_r_min} {ifco-l ran_1} {comp _r_rnd,%_r_max}
        {ifco-le ran_3}
        {subs _r_rnd,-1,1,%_r_rnd} {goto ran_1}
{:ran_3}{call rnddig} {subs _r_tmp,-1,1,%_rnd_tab} {comp _r_tmp,5}
        {ifco-le ran_1}
{:ran_2}{retu}
{:RNDDIG}
        {comp _rnd_tab} {ifco ,rnd_start}  Else randomize
        {setv _rnd_tab,%_24h} {mult _rnd_tab,60} {incr _rnd_tab,%_min}
        {mult _rnd_tab,60} {incr _rnd_tab,%_sec} {mult _rnd_tab,19%_yea}
{:rnd_start}
        {mult _rnd_tab,1255} {incr _rnd_tab,6173} {divi _rnd_tab,29282}
        {setv _rnd_tab,%_rem} {retu} This came from some asm source code!
The asm routine would only return 29282 different random numbers.  I 
implemeted the main random routine into another that builds it at a digit at 

time, to make the number as small or as large as needed.  Its random 
requency
I have not tested yet, but it isn't bad.
Carl
PS:  I'm not done, I'll post more updated copy later this week.
--- Renegade v10-05 Exp
---------------
** A related thread FOLLOWS this message.

FIDO MESSAGE AREA==> TOPIC: 153 COMMO         Ref: C5US2240 Date: 05/25/95
From: CHUCK SEYBOLDT                                        Time: 11:37pm
\/To: CARL MORRIS                                         (Read 6 times)
Subj: R: Re: Random Number Generat

CM>  Random number generation.  Variable _RND_TAB is permanent, do
CM>  not use it! Enter RANDOM with _r_min set to minimum value and
CM>  _r_max set to the maximum value.  Return is in _r_rnd.

Carl,

        Nice routine.  What you are basically doing is using the
previous random number as the seed for the next one ... here are the
guts of the random number generator, from both versions that you
have shared so far.

CM> {:rnd_start}
CM>         {mult _rnd_tab,1255}
CM>         {incr _rnd_tab,6173}
CM>         {divi _rnd_tab,29282}
CM>         {setv _rnd_tab,%_rem} {retu}

CM> 
CM>         {mult _rnd_tab,1256}
CM>         {incr _rnd_tab,6173}
CM>         {divi _rnd_tab,65535}

        Using 1256, 6173, and 65535, I got a loop that repeated
after 640 numbers (tried with several seeds).  This is obviously
undesirable.

        Using 1255, 6173, and 29282, results look much better!!
I specifically looked for the first random number to be present a
second time and it DID appear after 29279 numbers.  FWIW, Commo
wrote 39,000 numbers in 8 minutes on my 486/33 running DV.  I have a
sort running so I can search for duplicate/missing numbers and will
report on that separately.

        Using 1255, 6173, and 65535 repeated on a 96 number long
cycle.  There's a pattern in there .. but I'll be dipped if I can
figure it out.  I am picturing a loop/roulette wheel with the
multiply then increment rule that somehow lands once on each
compartment in a certain "random" pattern.

        I think a suitable seed (to initialize the generator) is
simply the %_sec variable, once you get into this random number
generator, it hops around quite well.

        Thanks for the details and a nice randomizer!

05/25/95   20:08                                        ChuckùS
---
 þ JABBER v1.3á1 #á021 þ {COMMO} a new standard in telecommunications.

---------------
** Current thread: Re: Random Number Generat

FIDO MESSAGE AREA==> TOPIC: 153 COMMO         Ref: C5VE1970 Date: 05/26/95
From: CHUCK SEYBOLDT                                        Time: 10:32am
\/To: CARL MORRIS                                         (Read 6 times)
Subj: R: Re: Random Number Generat

CM> {:rnd_start}
CM>         {mult _rnd_tab,1255}
CM>         {incr _rnd_tab,6173}
CM>         {divi _rnd_tab,29282}
CM>         {setv _rnd_tab,%_rem} {retu}
.
Carl,
.
        Finally got the complete list of numbers that this series
produces, and it indeed makes one of each number from 0 to 29281!
Neat thing is they are in a pseudo-random order.
.
        I don't know any other three numbers that share this
property, so for now this routine should use EXACTLY those values.
.
        It took Qedit almost an hour to sort the list into numerical
order!  The list is 193,864 bytes; 29,282 lines.

05/26/95   10:11                                        ChuckùS
---
 þ JABBER v1.3á1 #á021 þ {Commo} þ  Don't rank professionals with amateurs.

---------------
>>>>>>>>>>>>>>>>>>>>>> LAST Message In Thread <<<<<<<<<<<<<<<<<<<<<<

FIDO MESSAGE AREA==> TOPIC: 153 COMMO         Ref: C5V00000 Date: 05/25/95
From: FRED BRUCKER                                          Time: 10:14am
\/To: BOB JUGE                                            (Read 6 times)
Subj: OS2 AND COMMO

BJ} The defaults work great here.
Whew! 
                                - Fred -
---
 * SLMR 2.1a #359 *                                     
--- WILDMAIL!/WC v4.12 
---------------
* Origin: Hooper Connections -Home of SuperDir- 402-654-2102 (1:285/302)
* Origin: The Computer Room-Pickerington, Oh (614)861-8377 (1:226/110.0)

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™.