; ; rand.sh ; ; Generating random numbers ; ; © 1994-1998 Straylight ; ;----- Licensing note ------------------------------------------------------- ; ; This file is part of Straylight's Sapphire library. ; ; Sapphire is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2, or (at your option) ; any later version. ; ; Sapphire is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with Sapphire. If not, write to the Free Software Foundation, ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;----- Overview ------------------------------------------------------------- ; ; Functions provided: ; ; rand ; rand_setSeed ; rnd ; rand_init [ :LNOT::DEF:rand__dfn GBLL rand__dfn ; --- rand --- ; ; On entry: -- ; ; On exit: R0 == a pseudorandom number between 0 and &7FFFFFFF ; ; Use: Returns a pseudorandom number. The algorithm used is the ; additive generator found in Knuth. The table is generated ; from the current monotonic time using a linear congruential ; generator. Randomness is fairly good, and it's very quick. IMPORT rand ; --- rand_setSeed --- ; ; On entry: R0 == a pseudorandom seed ; ; On exit: -- ; ; Use: Sets up the random number generator (rand) to the given start ; position. The table of values is initialised from the seed ; in a psuedorandom manner, using a linear congruential ; generator. IMPORT rand_setSeed ; --- rnd --- ; ; On entry: R0 == start value (inclusive) ; R1 == end value (inclusive) ; ; On exit: R0 == random number between the boundaries given ; ; Use: Returns a random integer between the boundaries given. ; The distribution is slightly skewed towards lower numbers, ; but there's not a lot I can do about this, folks. IMPORT rnd ; --- rand_init --- ; ; On entry: -- ; ; On exit: -- ; ; Use: Initialise the random number table. IMPORT rand_init ] ;----- That's all, folks ---------------------------------------------------- END