projects
/
clnl
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add CL style
[clnl]
/
src
/
main
/
random.lisp
diff --git
a/src/main/random.lisp
b/src/main/random.lisp
index 6f500a979558a57fdd519d4323878ab43a5e8052..d8a38c0a4cbaf400ec3d36150a8a65b949e3d07e 100644
(file)
--- a/
src/main/random.lisp
+++ b/
src/main/random.lisp
@@
-2,9
+2,11
@@
; This is a wrapper around the very nice mersenne twister mt19937 to match
; NetLogo's implementation that tries to match how java.util.Random works
; This is a wrapper around the very nice mersenne twister mt19937 to match
; NetLogo's implementation that tries to match how java.util.Random works
-
+
(defun set-seed (n)
(defun set-seed (n)
- (setf mt19937:*random-state* (mt19937::make-random-object :state (mt19937:init-random-state n))))
+ (setf mt19937:*random-state* (funcall
+ (symbol-function (intern "MAKE-RANDOM-OBJECT" :mt19937))
+ :state (mt19937:init-random-state n))))
(defun next-int (n)
(if
(defun next-int (n)
(if
@@
-16,11
+18,11
@@
(let
((y (mt19937:random-chunk mt19937:*random-state*))
(z (mt19937:random-chunk mt19937:*random-state*)))
(let
((y (mt19937:random-chunk mt19937:*random-state*))
(z (mt19937:random-chunk mt19937:*random-state*)))
- (*
- (/
- (+ (ash (ash y -6) 27) (ash z -5))
- (coerce (ash 1 53) 'double-float))
- n)))
+
(*
+
(/
+
(+ (ash (ash y -6) 27) (ash z -5))
+
(coerce (ash 1 53) 'double-float))
+
n)))
; Oh, export world, you WILL be mine
(defun export ()
; Oh, export world, you WILL be mine
(defun export ()
@@
-29,7
+31,7
@@
(map
'list
(lambda (x) (if (logbitp (1- 32) x) (dpb x (byte 32 0) -1) x))
(map
'list
(lambda (x) (if (logbitp (1- 32) x) (dpb x (byte 32 0) -1) x))
- (
mt19937::random-state-state
mt19937:*random-state*))))
+ (
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))))
(format nil "0 ~A ~A ~A 0.0 false ~{~A~^ ~}"
(first state) (second state) (third state)
(nthcdr 3 state))))