SmartAgentBase.weOwnContsArround Scope

AI discussion, ideas, and SDK help.
Post Reply
jaybird
Luxer
Posts: 29
Joined: Sun Apr 23, 2006 6:53 pm
Location: Pittsburgh

SmartAgentBase.weOwnContsArround Scope

Post by jaybird » Wed Apr 26, 2006 8:07 pm

I cloned BetterPixie as Sparrow and found that the SmartAgentBase.weOwnContsArround method is problematic asside from its misspelling. While BetterPixie can use it, Sparrow cannot. It appears that when Sparrow is added to the ...lux/support/agent dir of the runtime, it is not treated as a member of the com.sillysoft.lux.agent package and hence has problems accessing this method with default class access (you get a java.lang.IllegalAccessError exception). I was able to override the method within Sparrow, but I think the default declaration of the weOwnContsArround method in SmartAgentBase (the only declaration in that class that is not 'public' or 'protected') was an oversite.

Again, I'm sorta of a newbie, and appreciate any suggestions, corrections, or clarifications re. this observation.

User avatar
GregM
Luxer
Posts: 252
Joined: Wed Jun 01, 2005 4:33 pm

Post by GregM » Wed Apr 26, 2006 8:34 pm

jaybird wrote:...it appears that when Sparrow is added to the ...lux/support/agent dir of the runtime, it is not treated as a member of the com.sillysoft.lux.agent package and hence has problems accessing this method with default class access (you get a java.lang.IllegalAccessError exception)...
To get a class into a package, you need to both have the class in the proper directory and have a package declaration at the top of the .java file. So, if you want Sparrow in the "com.sillysoft.lux.agent" package you need to put the statement "package com.sillysoft.lux.agent;" at the beginning of Sparrow.java.

Good luck with your bot. It would be nice to have another AI around. :)

jaybird
Luxer
Posts: 29
Joined: Sun Apr 23, 2006 6:53 pm
Location: Pittsburgh

Post by jaybird » Wed Apr 26, 2006 9:13 pm

Thanks, Greg, but that statement exists in Sparrow as it was a clone of BetterPixie; i.e., that isn't the prob.

User avatar
dustin
Lux Creator
Lux Creator
Posts: 10916
Joined: Thu May 15, 2003 2:01 am
Location: Cascadia
Contact:

Post by dustin » Thu Apr 27, 2006 7:02 am

You are correct that the missing 'protected' was an oversite. It will be added.

_hugo_
Lux Newbie
Posts: 2
Joined: Wed Dec 24, 2008 2:08 pm
Location: Montreal

Post by _hugo_ » Wed Dec 24, 2008 2:22 pm

I've had the same issue, but when cloning EvilPixie. The new class couldn't access outnumberBy and ourConts (which have the default modifier in Pixie.java). I do have the "package com.sillysoft.lux.agent;" statement at the first line of the file.

I could get rid of this problem by defining those two fields in my cloned class, but then I fear calls to inherited methods from Pixie that use those variables will use the value of the Pixie fields, not those of the cloned EvilPixie class...

I'm a bit rusted in Java, so sorry if this is dumb question, but could you explain what exactly is the problem here, and how I should solve it?

Thanks!

Post Reply