1
;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2
;;;; *************************************************************************
3
;;;; FILE IDENTIFICATION
6
;;;; Purpose: Random number functions for KMRCL package
7
;;;; Programmer: Kevin M. Rosenberg
8
;;;; Date Started: Apr 2000
10
;;;; $Id: random.lisp 8573 2004-01-29 23:30:50Z kevin $
12
;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
14
;;;; KMRCL users are granted the rights to distribute and use this software
15
;;;; as governed by the terms of the Lisp Lesser GNU Public License
16
;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17
;;;; *************************************************************************
21
(defun seed-random-generator ()
22
"Evaluate a random number of items"
23
(let ((randfile (make-pathname
24
:directory '(:absolute "dev")
26
(setf *random-state* (make-random-state t))
27
(if (probe-file randfile)
29
(rfs randfile :element-type 'unsigned-byte)
31
;; ((seed (char-code (read-char rfs))))
32
((seed (read-byte rfs)))
33
;;(format t "Randomizing!~%")
35
for item from 1 to seed
37
for it from 0 to (+ (read-byte rfs) 5)
38
do (random 65536))))))))
41
(defmacro random-choice (&rest exprs)
42
`(case (random ,(length exprs))
44
(mapcar #'(lambda (expr)