;;AUTOLOAD: random
;;AUTODOC: random "simple random number generator"
;;(random)
;;
;; Returns a random real number between 0 and 1 each time it is called
;;The seed can be set as it is the integer value "random:seed", which can
;;takes integer values between 0 and random:max
;;(random N) returns an integer number between 0 and N-1 inclusive

(defvar random:max 6075)		;or 100000
(defvar random:mult 106)		;or 21421
(defvar random:add 1283)		;or 1

(defvar random:seed (apply + (cur-date)))

(defun random (&optional ceiling)
  (setq random:seed (mod (+ (* random:seed random:mult) random:add) random:max))
  (if ceiling
    (/ (* random:seed ceiling) random:max)
    (/ random:seed (Real random:max))
  )
)
