X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=clnl;a=blobdiff_plain;f=src%2Fmain%2Frandom.lisp;h=44a1a2af0531f6d48e40109cbfa04f9283369bc1;hp=7fca5a183d4360398f9ac129b2275067b5891da7;hb=1ae8c7a0199a4955708c7f5d7a286a12782b5fd2;hpb=a0f8850031d5821c69b286d17004166f870fcd8e diff --git a/src/main/random.lisp b/src/main/random.lisp index 7fca5a1..44a1a2a 100644 --- a/src/main/random.lisp +++ b/src/main/random.lisp @@ -1,7 +1,3 @@ -(defpackage #:cl-nl.random - (:use :common-lisp) - (:export :set-seed :next-int :next-double)) - (in-package #:cl-nl.random) ; This is a wrapper around the very nice mersenne twister mt19937 to match @@ -22,3 +18,15 @@ (+ (ash (ash y -6) 27) (ash z -5)) (coerce (ash 1 53) 'double-float)) n))) + +; Oh, export world, you WILL be mine +(defun export () + (let + ((state + (map + 'list + (lambda (x) (if (logbitp (1- 32) x) (dpb x (byte 32 0) -1) x)) + (mt19937::random-state-state mt19937:*random-state*)))) + (format nil "0 ~A ~A ~A 0.0 false 1 ~{~A~^ ~}" + (first state) (second state) (third state) + (nthcdr 4 state))))