+ (*
+ (/
+ (+ (ash (ash y -6) 27) (ash z -5))
+ (coerce (ash 1 53) 'double-float))
+ n)))
+
+; Oh, export world, you WILL be mine
+(defun export ()
+ "EXPORT => RANDOM-STATE
+
+ARGUMENTS AND VALUES:
+
+ RANDOM-STATE: A dump of the current random state
+
+DESCRIPTION:
+
+ EXPORT dumps out the random state to be export world ready.
+
+ When NetLogo dumps out the current state of the engine, the state of the
+ RNG also gets dumped out so that it can be reinitialized later. This
+ accomplishes that.
+
+ This isn't really useful for regular use."
+ (let
+ ((state
+ (map
+ 'list
+ (lambda (x) (if (logbitp (1- 32) x) (dpb x (byte 32 0) -1) x))
+ (funcall (symbol-function (intern "RANDOM-STATE-STATE" :mt19937)) mt19937:*random-state*))))
+ (format nil "0 ~A ~A ~A 0.0 false ~{~A~^ ~}"
+ (first state) (second state) (third state)
+ (nthcdr 3 state))))