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

2012-03-13 Thread Wolfgang Laun
If you rely heavily on enums, you might consider using a userfunction
that binds enum constants to Jess variables - so you don't need the
parentheses.

http://www.jessrules.com/jesswiki/view?BindEnumUserFunction

-W

On 12/03/2012, 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.commailto:mcmil...@gmail.com
 Reply-To: jess-users@sandia.govmailto:jess-users@sandia.gov
 Date: Mon, 12 Mar 2012 15:59:45 -0400
 To: jess-users@sandia.govmailto: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.govmailto: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 

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

2012-03-13 Thread Wolfgang Laun
The posted error message still puzzles me. My recollection has it that
Jess reports quite accurately the statement where the exception was
raised, not just the outermost control statement. Moreover, all levels
between the outermost and innermost statement are displayed as well,
so that you can accurately trace the execution path.

If can provoke the reported error using this code:

(deffunction foo ())
(bind ?list (list a b c))
(try
  (foreach ?elem ?list
(printout t ?elem crlf)
(bind ?x (call foo ()))
  )
catch
  (printout t (call ?ERROR toString) crlf)
)

But I get this lucid information (Jess 7.1p2):

class jess.JessException
Jess reported an error in routine Value.stringValue
while executing (call foo )
while executing (bind ?x (call foo ))
while executing (foreach ?elem ?list (printout t ?elem crlf) (bind ?x
(call foo ))).
  Message: '' is a list, not  a string.

Was the original post produced by some older Jess version?

-W

On 10/03/2012, Hunter McMillen mcmil...@gmail.com wrote:
 I am receiving the error in the subject line when one of my rules is
 firing. I can't seem to find any other forum posts about it, here is my
 rule:

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

 and here is the exact error message:

 while executing (foreach ?u (call ?*bwapi* getMyUnits)
(if (= (call ?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 (call ?u getID)
 ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
(break))).

   Message: '' is a list, not  a string.

 But the error doesn't give me a line number.

 Any help would be appreciated.
 Thanks,
 Hunter McMillen



To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




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

2012-03-12 Thread Wolfgang Laun
Are you sure that
   (?*bwapi* getMyUnits)
returns a list?

Jess' foreach isn't quite as tolerant as for in Java 1.5 and later.
You may have to return an java.util.iterator.

-W


On 10/03/2012, Hunter McMillen mcmil...@gmail.com wrote:
 I am receiving the error in the subject line when one of my rules is
 firing. I can't seem to find any other forum posts about it, here is my
 rule:

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

 and here is the exact error message:

 while executing (foreach ?u (call ?*bwapi* getMyUnits)
(if (= (call ?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 (call ?u getID)
 ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
(break))).

   Message: '' is a list, not  a string.

 But the error doesn't give me a line number.

 Any help would be appreciated.
 Thanks,
 Hunter McMillen



To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




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

2012-03-12 Thread Hunter McMillen
Thanks for your response Wolfgang,

Yes, getMyUnits() returns an ArrayListUnit; I don't believe this likely
to be the problem since I have these in other rules that are functioning.
More debugging shows that the error is occurring in routine
Value.stringValue. Do you see anywhere where I am trying to get the string
value of a list?

Hunter
 On Mon, Mar 12, 2012 at 9:38 AM, Wolfgang Laun wolfgang.l...@gmail.comwrote:

 Are you sure that
   (?*bwapi* getMyUnits)
 returns a list?

 Jess' foreach isn't quite as tolerant as for in Java 1.5 and later.
 You may have to return an java.util.iterator.

 -W


 On 10/03/2012, Hunter McMillen mcmil...@gmail.com wrote:
  I am receiving the error in the subject line when one of my rules is
  firing. I can't seem to find any other forum posts about it, here is my
  rule:
 
  (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)
  )
  )
 
  and here is the exact error message:
 
  while executing (foreach ?u (call ?*bwapi* getMyUnits)
 (if (= (call ?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 (call ?u getID)
  ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
 (break))).
 
Message: '' is a list, not  a string.
 
  But the error doesn't give me a line number.
 
  Any help would be appreciated.
  Thanks,
  Hunter McMillen
 

 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
 




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

2012-03-12 Thread Jason Morris
The other place that it might be is in the line

 (if (= (call ?u getTypeID) ?*SCV_ID*) then ...

because the = function does a comparison by *value*, so it would likely
use Value.getValue().

What do your ID's look like?  Are they numbers or strings, or something
else?
If they are strings, then you need to use eq not =.  If they are some
object, then the type has to implement Comparable so that the value
comparison can be made.

Also, there might be some side effects of the call function that you keep
using.  Particularly that Jess returns coerces Arrays into lists.  Really,
you only need it for calling static methods on classes.  See the
Description for call
http://www.jessrules.com/jess/docs/71/functions.html#callin the jess
docs.  .. *When calling Java methods, arguments are promoted and
overloaded methods selected precisely as for
newhttp://www.jessrules.com/jess/docs/71/functions.html#new.
The return value is converted to a suitable Jess value before being
returned. Array return values are converted to lists.* 

On Tue, Mar 13, 2012 at 1:43 AM, Hunter McMillen mcmil...@gmail.com wrote:

 Thanks for your response Wolfgang,

 Yes, getMyUnits() returns an ArrayListUnit; I don't believe this likely
 to be the problem since I have these in other rules that are functioning.
 More debugging shows that the error is occurring in routine
 Value.stringValue. Do you see anywhere where I am trying to get the string
 value of a list?

 Hunter

  On Mon, Mar 12, 2012 at 9:38 AM, Wolfgang Laun 
 wolfgang.l...@gmail.comwrote:

 Are you sure that
   (?*bwapi* getMyUnits)
 returns a list?

 Jess' foreach isn't quite as tolerant as for in Java 1.5 and later.
 You may have to return an java.util.iterator.

 -W


 On 10/03/2012, Hunter McMillen mcmil...@gmail.com wrote:
  I am receiving the error in the subject line when one of my rules is
  firing. I can't seem to find any other forum posts about it, here is my
  rule:
 
  (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)
  )
  )
 
  and here is the exact error message:
 
  while executing (foreach ?u (call ?*bwapi* getMyUnits)
 (if (= (call ?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 (call ?u getID)
  ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
 (break))).
 
Message: '' is a list, not  a string.
 
  But the error doesn't give me a line number.
 
  Any help would be appreciated.
  Thanks,
  Hunter McMillen
 

 
 To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
 in the BODY of a message to majord...@sandia.gov, NOT to the list
 (use your own address!) List problems? Notify owner-jess-us...@sandia.gov
 .
 





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


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

2012-03-12 Thread Hunter McMillen
Here is the stacktrace:
 Message: '' is a list, not  a string.
   at jess.Value.a(Unknown Source)
   at jess.Value.a(Unknown Source)
   at jess.Value.a(Unknown Source)
   at jess.Value.stringValue(Unknown Source)
   at jess.Value.symbolValue(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.ce.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.FuncallValue.resolveValue(Unknown Source)
   at jess.i.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)

The first line in my code that the trace lists is where I run the engine
from my Java application:

   engine.run();


Hunter

On Mon, Mar 12, 2012 at 11:40 AM, Friedman-Hill, Ernest
ejfr...@sandia.govwrote:

  Hmmm. If that's the whole error message, then the error should be
 occurring executing that foreach function, not a function nested inside
 it; otherwise there would be more context information. But foreach
 doesn't try to coerce anything into a string, so that doesn't make sense.

  Inside your catch block,  do this:

  (?ERROR printStackTrace)

  And show us what you get; that should narrow it down quite a bit.


   From: Hunter McMillen mcmil...@gmail.com
 Reply-To: jess-users@sandia.gov
 Date: Fri, 9 Mar 2012 23:10:06 -0500
 To: jess-users@sandia.gov
 Subject: JESS: [EXTERNAL] Jess exception: ' ' is a list, not a string

  I am receiving the error in the subject line when one of my rules is
 firing. I can't seem to find any other forum posts about it, here is my
 rule:

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

  and here is the exact error message:

  while executing (foreach ?u (call ?*bwapi* getMyUnits)
(if (= (call ?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 (call ?u getID)
 ?p.x ?p.y (UnitType$UnitTypes.Terran_Supply_Depot ordinal))
(break))).

Message: '' is a list, not  a string.

  But the error doesn't give me a line number.

  Any help would be appreciated.
 Thanks,
 Hunter McMillen



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

2012-03-12 Thread Hunter McMillen
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.govwrote:

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




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

2012-03-12 Thread Jason Morris
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.govwrote:

  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