> 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
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
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