Java exceptions with bot controlling several "sub-bots&
Posted: Wed Dec 31, 2008 10:58 am
I've been slowly getting to know about the bots SDK, and as a first attempt at bot-writing, I've written a very simple bot that just randomly switches control of the bot's action to other hard "sub-bots", such as Reaper, Killbot, EvilPixie and others (kind of like Chimera). To do this, I simply create instances of those "sub-bots" in the setPrefs() method, and I call their setPrefs method with the given newID and theboard values, as follows:
Then, in placeArmies(), attackPhase(), moveArmies() and fortifyPhase(), I randomly select one of the sub-bots to take action, by calling the associated method of the sub-bot.
Unfortunately, my problem right now is that I keep getting java.lang.NullPointerException errors. My problem seems to be similar actually to that reported here: http://sillysoft.net/forums/viewtopic.php?p=55385. I also get this sort of exception sometimes:
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1176)
at com.sillysoft.lux.B.A(Unknown Source)
at com.sillysoft.lux.B.A(Unknown Source)
at com.sillysoft.lux.Board.attack(Unknown Source)
at com.sillysoft.lux.Board.attack(Unknown Source)
at com.sillysoft.lux.agent.SmartAgentBase.attackForCard(Unknown Source)
at com.sillysoft.lux.agent.SmartAgentBase.attackForCard(Unknown Source)
at com.sillysoft.lux.agent.BetterPixie.attackPhase(Unknown Source)
at com.sillysoft.lux.agent.Vulture.attackPhase(Unknown Source)
at com.sillysoft.lux.B._(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:613)
Has anyone ever stumbled on this issue and found a way to resolve it? That would be great, as my idea for a new AI bot is centered around the use of other sub-bots...
Thanks!
Code: Select all
public void setPrefs( int newID, Board theboard )
{
ID = newID;
board = theboard;
countries = board.getCountries();
numCountries = countries.length;
numContinents = board.getNumberOfContinents();
agents = new LuxAgent[5];
agents[0] = new Killbot();
agents[1] = new Boscoe();
agents[2] = new Quo();
agents[3] = new Reaper();
agents[4] = new EvilPixie();
for( int i=0; i<agents.length; i++)
agents[i].setPrefs(newID, theboard);
}
Unfortunately, my problem right now is that I keep getting java.lang.NullPointerException errors. My problem seems to be similar actually to that reported here: http://sillysoft.net/forums/viewtopic.php?p=55385. I also get this sort of exception sometimes:
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1176)
at com.sillysoft.lux.B.A(Unknown Source)
at com.sillysoft.lux.B.A(Unknown Source)
at com.sillysoft.lux.Board.attack(Unknown Source)
at com.sillysoft.lux.Board.attack(Unknown Source)
at com.sillysoft.lux.agent.SmartAgentBase.attackForCard(Unknown Source)
at com.sillysoft.lux.agent.SmartAgentBase.attackForCard(Unknown Source)
at com.sillysoft.lux.agent.BetterPixie.attackPhase(Unknown Source)
at com.sillysoft.lux.agent.Vulture.attackPhase(Unknown Source)
at com.sillysoft.lux.B._(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:613)
Has anyone ever stumbled on this issue and found a way to resolve it? That would be great, as my idea for a new AI bot is centered around the use of other sub-bots...
Thanks!