Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Clisp randomness

6 views
Skip to first unread message

bruce

unread,
Apr 22, 2002, 9:13:21 PM4/22/02
to
I'm trying to write a card-playing game using Clisp, and am running
into the problem of not getting a very "random" number from the
RANDOM function. It's producing the same two hands on every start
in a fresh Clisp, thus the game tends to play much the same way each
time it's run. How can I either find something random to set to
*random-state*, or else find some other function to fill this gap?

Any enlightenment would be helpful, as I'm still firmly in the newbie
stages...

Thanks,
Bruce H. Nagel
lost...@innocent.com

Gabe Garza

unread,
Apr 22, 2002, 9:22:08 PM4/22/02
to
lost...@Bast.debian.org (bruce) writes:

Enlightenment lies within the Common Lisp HyperSpec, or CLHS as it's
commonly abbreviated (are you using CLisp from within Emacs via ilisp?
If so, take a look at one of the HyperSpec packages that will allow
you to look up symbols...)

The entry for MAKE-RANDOM-STATE reads:

HS> Creates a fresh object of type random-state suitable for use as the
HS> value of *random-state*.

HS> If state is a random state object, the new-state is a copy[5] of that
HS> object. If state is nil, the new-state is a copy[5] of the current
HS> random state. If state is t, the new-state is a fresh random state
HS> object that has been randomly initialized by some means.

Thus, something like

(setf *random-state* (make-random-state t))

is what you need...

Gabe Garza

bruce

unread,
Apr 22, 2002, 9:34:40 PM4/22/02
to
In article <pu0r1a...@kynopolis.org>, Gabe Garza wrote:

>> Any enlightenment would be helpful, as I'm still firmly in the newbie
>> stages...

>Enlightenment lies within the Common Lisp HyperSpec, or CLHS as it's
>commonly abbreviated (are you using CLisp from within Emacs via ilisp?
>If so, take a look at one of the HyperSpec packages that will allow
>you to look up symbols...)

Perhaps I lost patience in contemplating the koan; I was at least looking
in the right place. I was simply not applying the proper syntax.

Thank you for saving my forehead from impacting a wall; my walls are old
and have brick underneat the plaster. :)

Bruce H. Nagel
lost...@innocent.com

Erik Naggum

unread,
Apr 22, 2002, 10:11:41 PM4/22/02
to
* lost...@Bast.debian.org (bruce)

| I'm trying to write a card-playing game using Clisp, and am running into
| the problem of not getting a very "random" number from the RANDOM
| function. It's producing the same two hands on every start in a fresh
| Clisp, thus the game tends to play much the same way each time it's run.
| How can I either find something random to set to *random-state*, or else
| find some other function to fill this gap?

See the entry for the function random in the standard and follow the
links to the variable *random-state* and the function make-random-state.

///
--
In a fight against something, the fight has value, victory has none.
In a fight for something, the fight is a loss, victory merely relief.

Post with compassion: http://home.chello.no/~xyzzy/kitten.jpg

0 new messages