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,v 1.2 2002/10/06 13:30:17 kevin Exp $
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 GNU General Public License.
16 ;;;; *************************************************************************
20 (defun seed-random-generator ()
21 "Evaluate a random number of items"
22 (let ((randfile (make-pathname
23 :directory '(:absolute "dev")
25 (setf *random-state* (make-random-state t))
26 (if (probe-file randfile)
28 (rfs randfile :element-type 'unsigned-byte)
30 ;; ((seed (char-code (read-char rfs))))
31 ((seed (read-byte rfs)))
32 ;;(format t "Randomizing!~%")
34 for item from 1 to seed
36 for it from 0 to (+ (read-byte rfs) 5)
37 do (random 65536))))))))
40 (defmacro random-choice (&rest exprs)
41 `(case (random ,(length exprs))
43 (mapcar #'(lambda (expr)