please I need help quickly

95 views
Skip to first unread message

Elias

unread,
Jan 3, 2023, 4:14:56 AM1/3/23
to clip...@googlegroups.com
Why the code doesn't work ):  ?
aes (2).clp

denis.be...@gmail.com

unread,
Jan 3, 2023, 4:32:29 AM1/3/23
to CLIPSESG

When you parse the start of this rule:

(defrule process-input-allwrong

   (correctplace ?correctplace)

   (wrongplace ?wrongplace)

   (test (= ?correctplace 0))

   (test (= ?wrongplace 0))

   (digit (place first) (number ?fnum) (iscorrect ?fisc))

   (digit (place second) (number ?snum) (iscorrect ?sisc))

   (digit (place third) (number ?tnum) (iscorrect ?tisc))

   (digit (place fourth) (number ?fonum) (iscorrect ?foisc))

   =>

   (assert (wrongdigit (?fnum)))

)

you get the error message:

[EXPRNPSR1] A function name must be a symbol


It is easy to see where the problem is: (?fnum)
As the 1st argument to predicate wrongdigit starts with a parenthesis, CLIPS is expecting a function - which ?fnum is not.

Try with:

   (assert (wrongdigit ?fnum))

(and similar changes everywhere).


Elias

unread,
Jan 3, 2023, 5:03:33 AM1/3/23
to CLIPSESG
Thank you soooo much 
but there is another error can help me? 
Because I need the file to be correct as quickly as possible
thank u again  . .

Elias

unread,
Jan 3, 2023, 5:15:52 AM1/3/23
to CLIPSESG

(deffunction get-random-unwrong-numbe ()
   (wrongdigit ?num)
   (bind ?answer (+ 1 (mod (random) 9)))
   (while (= ?answer ?num)
      (bind ?answer (+ 1 (mod (random) 9)))
   )
   (return ?answer))

[EXPRNPSR3] Missing function declaration for wrongdigit.

ERROR:
(deffunction MAIN::get-random-unwrong-numbe
   ()
   (wrongdigit

[CSTRNCHK1] A literal slot value found in the modify command
does not match the allowed types for slot number.

ERROR:
(defrule MAIN::change-first-digit
   (fshouldchange ?fshouldchange)

   (digit (place first) (number ?fnum) (iscorrect ?fisc))
   ?Xhas <- (digit (place first) (number ?fnum) (iscorrect ?fisc))
   (test (= ?fshouldchange 1))
   (test (= ?fisc 0))
   =>
   (modify ?Xhas (number get-random-unwrong-numbe))
   (assert (fshouldchange 0)))

[CSTRNCHK1] A literal slot value found in the modify command
does not match the allowed types for slot number.

ERROR:
(defrule MAIN::change-second-digit
   (sshouldchange ?sshouldchange)

   (digit (place second) (number ?snum) (iscorrect ?sisc))
   ?Xhas <- (digit (place second) (number ?snum) (iscorrect ?sisc))
   (test (= ?sshouldchange 1))
   (test (= ?sisc 0))
   =>
   (modify ?Xhas (number get-random-unwrong-numbe))
   (assert (sshouldchange 0)))

[CSTRNCHK1] A literal slot value found in the modify command
does not match the allowed types for slot number.

ERROR:
(defrule MAIN::change-third-digit
   (tshouldchange ?tshouldchange)

   (digit (place third) (number ?tnum) (iscorrect ?tisc))
   ?Xhas <- (digit (place third) (number ?tnum) (iscorrect ?tisc))
   (test (= ?tshouldchange 1))
   (test (= ?tisc 0))
   =>
   (modify ?Xhas (number get-random-unwrong-numbe))
   (assert (tshouldchange 0)))

[TMPLTDEF1] Invalid slot digit not defined in corresponding deftemplate digit.

ERROR:
(defrule MAIN::change-fourth-digit
   (foshouldchange ?foshouldchange)
   (digit (digit

[EXPRNPSR3] Missing function declaration for -?correctplace.

ERROR:
(defrule MAIN::process-input-save-try-and-search-s
   (correctplace ?correctplace)
   (wrongplace ?wrongplace)
   (total-correct-digit (number ?tot))
   (test (> ?correctplace 0))
   (test (= ?wrongplace 0))
   (test (= (-?correctplace
[EVALUATN1] Variable snum is unbound
[ARGACCES5] Function = expected argument #1 to be of type integer or float
[COMMLINE1] Expected a '(', constant, or global variable
[COMMLINE1] Expected a '(', constant, or global variable
[EVALUATN1] Variable Xhas is unbound
[ARGACCES5] Function modify expected argument #1 to be of type non-void return value

[PRNTUTIL2] Syntax Error:  Check appropriate syntax for first field of a RHS pattern.
[EVALUATN1] Variable yhas is unbound
[ARGACCES5] Function modify expected argument #1 to be of type non-void return value
[COMMLINE1] Expected a '(', constant, or global variable

[EXPRNPSR3] Missing function declaration for -?correctplace.

ERROR:
(defrule MAIN::process-input-save-try-and-search-t
   (correctplace ?correctplace)
   (wrongplace ?wrongplace)
   (total-correct-digit (number ?tot))
   (test (> ?correctplace 0))
   (test (= ?wrongplace 0))
   (test (= (-?correctplace
[EVALUATN1] Variable tnum is unbound
[ARGACCES5] Function = expected argument #1 to be of type integer or float
[COMMLINE1] Expected a '(', constant, or global variable
[COMMLINE1] Expected a '(', constant, or global variable
[EVALUATN1] Variable Xhas is unbound
[ARGACCES5] Function modify expected argument #1 to be of type non-void return value

[PRNTUTIL2] Syntax Error:  Check appropriate syntax for first field of a RHS pattern.
[EVALUATN1] Variable yhas is unbound
[ARGACCES5] Function modify expected argument #1 to be of type non-void return value
[COMMLINE1] Expected a '(', constant, or global variable

[EXPRNPSR3] Missing function declaration for -?correctplace.

ERROR:
(defrule MAIN::process-input-save-try-and-search-fo
   (correctplace ?correctplace)
   (wrongplace ?wrongplace)
   (total-correct-digit (number ?tot))
   (test (> ?correctplace 0))
   (test (= ?wrongplace 0))
   (test (= (-?correctplace
[EVALUATN1] Variable fonum is unbound
[ARGACCES5] Function = expected argument #1 to be of type integer or float
[COMMLINE1] Expected a '(', constant, or global variable
[COMMLINE1] Expected a '(', constant, or global variable
[EVALUATN1] Variable Xhas is unbound
[ARGACCES5] Function modify expected argument #1 to be of type non-void return value

[PRNTUTIL2] Syntax Error:  Check appropriate syntax for first field of a RHS pattern.
[EVALUATN1] Variable yhas is unbound
[ARGACCES5] Function modify expected argument #1 to be of type non-void return value
[COMMLINE1] Expected a '(', constant, or global variable

[EXPRNPSR3] Missing function declaration for -?correctplace.

ERROR:
(defrule MAIN::process-input-save
   (correctplace ?correctplace)
   (wrongplace ?wrongplace)
   (test (> ?correctplace 0))
   (test (= ?wrongplace 0))
   (test (neq (-?correctplace

denis.be...@gmail.com

unread,
Jan 3, 2023, 6:31:35 AM1/3/23
to CLIPSESG
"(deffunction get-random-unwrong-numbe ()
   (wrongdigit ?num)
   (bind ?answer (+ 1 (mod (random) 9)))
   (while (= ?answer ?num) 
      (bind ?answer (+ 1 (mod (random) 9)))
   )
   (return ?answer))

[EXPRNPSR3] Missing function declaration for wrongdigit.
"

CLIPS literally tells you where the problem is:
[EXPRNPSR3] Missing function declaration for wrongdigit.
You have introduced "wrongdigit" as a unary predicate in rule "process-input-allwrong". That doesn't define it as a function. but now you're trying to use it as a function.
Reply all
Reply to author
Forward
0 new messages