Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

"Friedman-Hill, Ernest" <[email protected]> Mon, 12 Mar 2012 20:23:30 +0000
Newsgroups gmane.comp.java.jess
Message-ID <CB83D28E.9D24%[email protected]>
The Jess language is not Java, it's Lisp by design, and parentheses just work differently. All functions calls look like (fooFunction a b c), and if there's no arguments, it's just (fooFunction). There are never parentheses just surrounding the arguments.

For using enums, look here: http://www.jessrules.com/jesswiki/view?EnumeratedTypes . The upshot is that "import" will defined some functions for you which return the enum's values; to get the value, you have to call the function. So there's one more set of parentheses:

   ((UnitType$UnitTypes.Terran_Supply_Depot) ordinal)



From: Hunter McMillen <[email protected]<mailto:[email protected]>>
Reply-To: <[email protected]<mailto:[email protected]>>
Date: Mon, 12 Mar 2012 15:59:45 -0400
To: <[email protected]<mailto:[email protected]>>
Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

That was exactly the problem, thanks. What is the general rule for function calling in Jess, always without parentheses? I never would have caught that error because when I see something like get-next-build-tile() the parentheses tell me it is a function. Seeing it without the parens makes me think it is a variable, even without the ? sign is front.

Also, as a corollary question; I am using an enumerated type in my rule:

(import eisbot.proxy.types.UnitType$UnitTypes)

(defrule build-supply-depot
(minerals (value ?x&:(> ?x 100)))
=>
(try
(foreach ?u (?*bwapi* getMyUnits)
(if (= (?u getTypeID) ?*SCV_ID*) then
(bind ?p (call get-next-build-tile()))
(call ?*bwapi* drawCircle ?p.x ?p.y 100 111 FALSE FALSE)
(call ?*bwapi* build (?u getID) ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
(break)))
catch
(printout t (call ?ERROR toString) crlf)
)
)

But after importing when my rule tries to execute the bolded line above, I get a class not found exception:

  Message: Class not found.
        at jess.dx.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.dx.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.f4.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.FuncallValue.resolveValue(Unknown Source)
        at jess.cu.a(Unknown Source)
        at jess.cu.call(Unknown Source)
        at jess.ac.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.Defrule.a(Unknown Source)
        at jess.Activation.a(Unknown Source)
        at jess.en.a(Unknown Source)
        at jess.en.a(Unknown Source)
        at jess.Rete.if(Unknown Source)
        at jess.Rete.run(Unknown Source)
        at hunterai.HunterAIClient.gameUpdate(HunterAIClient.java:156)
        at eisbot.proxy.JNIBWAPI.gameUpdate(JNIBWAPI.java:795)
        at eisbot.proxy.JNIBWAPI.startClient(Native Method)
        at eisbot.proxy.JNIBWAPI.start(JNIBWAPI.java:597)
        at hunterai.HunterAIClient.start(HunterAIClient.java:102)
        at hunterai.HunterAIClient.main(HunterAIClient.java:42)
Caused by: java.lang.ClassNotFoundException: new
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at jess.dc.for(Unknown Source)
        at jess.dc.if(Unknown Source)
        at jess.Rete.findClass(Unknown Source)
        ... 28 more

any ideas?

Hunter




On Mon, Mar 12, 2012 at 1:48 PM, Friedman-Hill, Ernest <[email protected]<mailto:[email protected]>> wrote:
OK, I looked in the magic decoder file and I see a "call" being invoked inside a "bind", so that fits only the line of code below. And lo and behold, look at it: the second argument to "call", which should be the name of the function to call, is a pair of empty parentheses — i.e., a list. This line is asking Jess to to call the static method named "()" on the class named "get-next-build-tile" -- surely not what you intended. If you're just calling a deffunction by this name, then you just want

(bind ?p (get-next-build-tile))

From: Hunter McMillen <[email protected]<mailto:[email protected]>>
Reply-To: <[email protected]<mailto:[email protected]>>
Date: Mon, 12 Mar 2012 12:16:29 -0400
To: <[email protected]<mailto:[email protected]>>
Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

(bind ?p (call get-next-build-tile()))