[comp.sys.amiga.tech] Random

UH2@PSUVM.BITNET (Lee Sailer) (09/13/89)

<1989Sep13.032352.10321@agate.berkeley.edu> <60483@tut.cis.ohio-state.edu>

I disagree with this notion that each programmer should be responsible
for rolling a "good" RNG.  I've done this myself too many times, and know
what a pain it can be.  It would be better if the language vendor, eg AREXX,
Lattice, Manx, etc etc etc would do the leg work once, thus saving
hundreds or thousands of wheel reinventions.

Probably, each language should offer at least two RNGs.  One that is
very, very fast, even if it doesn't generate high quality numbers, and
another that generates very high quality numbers, even if it happens to
be a little slow.

Is this topic Amiga specific?  Well, not very much, excpet that we could
ask for each commonly used language which, if either, of these two RNGs
is offered.

           lee

mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) (09/14/89)

In article <89256.111549UH2@PSUVM.BITNET> UH2@PSUVM.BITNET (Lee Sailer) writes:
<<1989Sep13.032352.10321@agate.berkeley.edu> <60483@tut.cis.ohio-state.edu>
<I disagree with this notion that each programmer should be responsible
<for rolling a "good" RNG.  I've done this myself too many times, and know
<what a pain it can be.  It would be better if the language vendor, eg AREXX,
<Lattice, Manx, etc etc etc would do the leg work once, thus saving
<hundreds or thousands of wheel reinventions.

Actually, I don't like it either - which is why I suggested only for
serious applications, and using a known-good routine if you had one
available.

The reason for rolling your own is that it's easier than testing one
to verify that it is good. If that weren't true, then I'd recommend
testing the one that came with the language, and using that if it is
acceptable. 

<Is this topic Amiga specific?  Well, not very much, excpet that we could
<ask for each commonly used language which, if either, of these two RNGs
<is offered.

Actually, I'm about to make it Amiga-specific. This seems to be the
perfect place for CBM to step in, and provide a "random.library" that
offers a nice selection of "known-good" random number generators,
with various characteristics, including multiple interfaces so that
no real work has to be done to get the standard routines for all
languages popular on the Amiga (C, Modual-II, ARexx and whichever
Basic they ship with 1.4 would seem to be a bare minimum).

	<mike
--
I'm gonna lasso you with my rubberband lazer,		Mike Meyer
Pull you closer to me, and look right to the moon.	mwm@berkeley.edu
Ride side by side when worlds collide,			ucbvax!mwm
And slip into the Martian tide.				mwm@ucbjade.BITNET

kodiak@amiga.UUCP (Robert R. Burns) (09/16/89)

Try:

    extern ULONG RangeSeed;
    extern UWORD RangeRand( UWORD );	/* A.K.A. RangeRan */

    /*
     *  RangeRand -- ranged random function
     *
     *  INPUT
     *      range: 1 <= range < 65536
     *
     *  OUTPUT
     *      random number: 0 <= range < range
     */

Link w/ amiga.lib


This was written by Amiga's "Mgr. of Game Software" for the old Amiga
but didn't make it into the roms because we moved away from that focus.

I know it's in my copy of amiga.lib, and I suspect it's in yours too.
Let me know (via email) if it's not.  I can well imagine that it isn't
documented anywhere.


- Kodiak
-- 
Bob Burns, amiga!kodiak				   _
	| /_  _|. _ |	   Commodore __		  |_) _ |_  _ )'
	|<(_)(_)|(_\|<	    /\ |  ||| _` /\	  |_)(_\| )(_\ |
	| \ Software	___/..\|\/|||__|/..\___		   Faith