Good gravy!  This is one of those "can't see the forest through the trees"
examples that we used to collect on the jess wiki!  It was hiding in plain
sight!

One lesson from this is that Jess's error messages, even when seemingly
cryptic, contain some useful clues. Users, myself included, are too often
guilty of assuming that the message isn't useful or is mistaken when the
reality is the opposite.  Also, there *was *an indirect side-effect of
using call .. namely not knowing what arguments it was expecting.

On Tue, Mar 13, 2012 at 7:23 AM, Friedman-Hill, Ernest
<ejfr...@sandia.gov>wrote:

>  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 <mcmil...@gmail.com>
> Reply-To: <jess-users@sandia.gov>
> Date: Mon, 12 Mar 2012 15:59:45 -0400
>
> To: <jess-users@sandia.gov>
> 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 <ejfr...@sandia.gov
> > 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 <mcmil...@gmail.com>
>> Reply-To: <jess-users@sandia.gov>
>>  Date: Mon, 12 Mar 2012 12:16:29 -0400
>> To: <jess-users@sandia.gov>
>> Subject: Re: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string
>>
>>  (bind ?p (call get-next-build-tile()))
>>
>>
>


-- 
*Jason C. Morris*
President, Principal Consultant
Morris Technical Solutions LLC
President, Rules Fest Association
Chairman, IntelliFest 2012: International Conference on Reasoning
Technologies
--------------------------------------------
phone: +01.517.304.5883
skype: jcmorris-mts
email: consult...@morris-technical-solutions.com
mybio: http://www.linkedin.com/in/jcmorris


<http://www.intellifest.org%20>
www.intellifest.org
Invent * Innovate * Implement at IntelliFest!

Reply via email to