[CM] CM random seed
Rick Taube
taube@uiuc.edu
Sat, 21 May 2005 14:27:10 -0500
On May 21, 2005, at 11:23 AM, Joshua Parmenter wrote:
> Thanks Rick, that works.
> But how can I change the seeded value? Or save one (other then the
> one generated by nil) for later use (possibly in another session) if
> the printed one can't be manipulated? I know this will be different
> for different lisps, but I am more concerned with personal use, and I
> was able to do this not long ago (in CM 2.4). Now that code is broken,
> and I want to try and find a way to fix it.
> Josh
CL deliberately does not provide a way to seed random states. but
most implemenations probably have some mechanism -- in openmcl its
ccl::initialize-random-state. this is what ccl does in l1-numbers.lisp
:
(defparameter *random-state* (initialize-random-state #xFBF1 9))
as far as saving random-states go, you should be able to print them to
a file and read them back in. Most Lisps print random states using the
#S read macro for just this reason -- i dont know why ccl uses #. since
random-state cannot be a function.
I guess you could redefine the print-object method for random states
to print like this:
#.(ccl::initialize-random-state nnn nnn)
anyway cm has nothing to do with this stuff, its up to the underlying
lisp to provide something (or not). if it worked in cm 2.4 then it was
probably only because ccl was letting you do something that it no
longer allows.