Lux Delux AI Secondary Class Build Question

AI discussion, ideas, and SDK help.
Post Reply
jman84
Lux Newbie
Posts: 4
Joined: Sun Apr 12, 2020 1:31 am

Lux Delux AI Secondary Class Build Question

Post by jman84 » Sun Apr 12, 2020 1:38 am

I recently got this game and am starting to work on an AI bot. That's one of the cooler features of this game and part of the reason why I chose to get it. I have the SDK downloaded and made a simple Hello World-style bot that doesn't do much, but it confirmed that I can get a bot to run and attack.

The issue I have is I cannot figure how to create and use another class in my bot. I had my bot BigBadBot.java. Now I want to create a class called LuxGraph.java. The code compiles, but I always get this stack trace

Code: Select all

java.lang.NoClassDefFoundError: com/sillysoft/lux/agent/BigBoyBot$LuxGraph
	at com.sillysoft.lux.agent.BigBoyBot.placeArmies(BigBoyBot.java:44)
	at com.sillysoft.lux.B.T(Unknown Source)
	at com.sillysoft.lux.B.h(Unknown Source)
	at com.sillysoft.lux.B.P(Unknown Source)
	at com.sillysoft.lux.B.run(Unknown Source)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException
	at com.sillysoft.lux.L.loadClass(Unknown Source)
	at com.sillysoft.lux.L.loadClass(Unknown Source)
	... 6 more
Some things I tried: include the code for the LuxGraph class in BigBadBot.java. Didn't work, got the same result.
Then, I made LuxGraph a nested class within BigBadBot. Also didn't work. I don't see why it would not work now, because it's inside BigBadBot so shouldn't that code be included when Lux runs BigBadBot?
Last edited by dustin on Tue Apr 14, 2020 7:02 pm, edited 1 time in total.

jman84
Lux Newbie
Posts: 4
Joined: Sun Apr 12, 2020 1:31 am

Re: Lux Delux AI Build Question

Post by jman84 » Sun Apr 12, 2020 4:08 am

"I don't see why it would not work now, because it's inside BigBadBot so shouldn't that code be included when Lux runs BigBadBot?"

I just read on StackOverflow that nested classes, when compiled, are not still nested in their parent class. So that explains why that was not working, though I still can't figure out how to include another .class file.

I tried putting BigBadBot.class into the Lux/Agents folder where all my downloaded agents are and I got the message when starting that BigBadBot is not a LuxAgent. So it looks like all of the classes in that directory are only loaded if they implement LuxAgent. Then I made it implement LuxAgent with dummy methods that do nothing just to see if it can then be included, but that still did not work.

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

Re: Lux Delux AI Build Question

Post by dustin » Tue Apr 14, 2020 1:57 pm

It can definitely be done. Install Tactobot from the plugin manager, and you can see how its files get located. Seems like main class file inside /Agents directly and then other classes inside a folder path based on their package.

Oponn agent also seems to use many other classes for functions.

It's been a while since I've delved into specifics of this. Hope this helps!

jman84
Lux Newbie
Posts: 4
Joined: Sun Apr 12, 2020 1:31 am

Re: Lux Delux AI Build Question

Post by jman84 » Tue Apr 14, 2020 5:06 pm

Ah, thanks for pointing me towards Tactobot. I followed how that worked and got it working for me!

Post Reply

Who is online

Users browsing this forum: No registered users and 54 guests