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

CLIPS random number generator

696 views
Skip to first unread message

Gary Riley

unread,
Mar 3, 1995, 11:00:48 AM3/3/95
to
In article <3j4v92$c...@newstand.syr.edu>, jay...@hydra.syr.edu (Slug) wrote:

> Hello,
> I did a text search of the clips-faq and didn't see any
> mention of this, but I am working on a expert-system to play
> backgammon, using CLIPS 6.0 for Unix. I wrote all the
> code for initializing the board and user-input, and I used a C
> program to output the board state. Now I was trying to get the
> (random) function to work, but it seems to always return 0.

Using an ANSI C compiler, you'll have to recompile CLIPS with the
ANSI_COMPILER flag in setup.h enabled. There's a note in the
Basic Programming Guide in section 12.7.4, which describes the random
function, indicating that random always returns zero if the
ANSI_COMPILER flag is disabled. You can determine the compiler
settings for CLIPS by issuing an (options) command from the command
prompt.

Gary Riley

Mike Moran

unread,
Mar 3, 1995, 11:05:18 AM3/3/95
to


Will Dwinnell writes:
In article <BE141q-....@delphi.com> Will Dwinnell <pred...@delphi.com> writes:


predictor> Slug <jay...@hydra.syr.edu> writes:
>> Could somebody kindly tell me what I'm doing wrong.. it's gotta be
>> something dumb on my part, but I can't seem to find out why...


predictor> I don't know CLIPS, but this...


>> (dice (+ 1 (mod (random) 5)) (+ 1 (mod (random) 5)))) ...)

predictor> looks like you might be mixing integer (mod) and decimal (random)
predictor> representations. What sort of numbers are supposed to come off of
predictor> random? Often, languages give a random function which delivers
predictor> decimal values between 0.0 and 1.0. Your system may be truncating or
predictor> the "random" to the integer 0. Just a thought...

predictor> Will Dwinnell
predictor> pred...@delphi.com
predictor> 610-917-0594
predictor> Commercial Intelligence Inc.

I've just started using CLIPS locally, and, from what i can remember,
if CLIPS (the C-code which runs CLIPS, not user CLIPS programs) is
compiled with (or without, i can't remember) a certain command line
switch, then (random) will always return zero. It's mentioned
*somewhere* in the manual (i don't know; as it was a friend who had
this same problem, not me), so maybe you should recompile (or ask
somebody else to) CLIPS?

Thanks,

Mike

Slug

unread,
Mar 2, 1995, 12:29:06 PM3/2/95
to
Hello,
I did a text search of the clips-faq and didn't see any
mention of this, but I am working on a expert-system to play
backgammon, using CLIPS 6.0 for Unix. I wrote all the
code for initializing the board and user-input, and I used a C
program to output the board state. Now I was trying to get the
(random) function to work, but it seems to always return 0.

I am trying to simulate dice, i.e. integer from 1-6.

so I seed the RNG with

(seed <some large prime number>)

and then I assert the following:

(assert (board

...
(dice (+ 1 (mod (random) 5)) (+ 1 (mod (random) 5)))) ...)

now, this always asserts 1's (I add 1 to the result of random),
I also tried to see if I was doing

something wrong the following:

(assert (board
...
(dice (random) (random))))

just for testing purposes and this always asserts 0's


Could somebody kindly tell me what I'm doing wrong.. it's gotta be
something dumb on my part, but I can't seem to find out why...

Alternatively, is anybody have any examples of how to use the RNG
in CLIPS, (i'm trying to avoid calling too many C programs!)

thanks, and feel free
to email me at the above address

Jay


--
. . . . http://www.npac.syr.edu/REU/reu94/jayhui/homepage.html
_!/ _!/ jay...@mailbox.syr.edu
.::-' _> .::-' _> jay...@npac.syr.edu
:::____/ .:::____/ cps...@npac.syr.edu

Will Dwinnell

unread,
Mar 2, 1995, 7:21:59 PM3/2/95
to
Slug <jay...@hydra.syr.edu> writes:

>Could somebody kindly tell me what I'm doing wrong.. it's gotta be
>something dumb on my part, but I can't seem to find out why...


I don't know CLIPS, but this...


> (dice (+ 1 (mod (random) 5)) (+ 1 (mod (random) 5)))) ...)

looks like you might be mixing integer (mod) and decimal (random)
representations. What sort of numbers are supposed to come off of
random? Often, languages give a random function which delivers
decimal values between 0.0 and 1.0. Your system may be truncating or
the "random" to the integer 0. Just a thought...

Will Dwinnell
pred...@delphi.com
610-917-0594
Commercial Intelligence Inc.
0 new messages