A threading issue?

A threading issue?

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
hangfire
Posts: 14
Joined: 06 Nov 2010, 08:31

A threading issue?

Post by hangfire »

Good day,

I hope someone can give me a few pointers on an issue.
I've noticed that when you have multiple occurances of the same bot that events are called multiple times. I'll give an example to explain what i'm trying to say

Firstly I'm working with java, so the best place to start is with the NullOOJavaAI code. If I make no changes to the code and simply run a game of BA with 2 NullOOJavaAI bots, then in log-team-0.txt I can see the lines "initializing team 0" AND "initializing team 1", whereas in log-team-1.txt I only see "initializing team 1".

So it's as if the init method for the first instance of the bot is called, when the second instance of the bot's init method is called.

Now when I start to add my own code to say the unitCreated method, again the first instance of the bot's unitCreated method will get called for the same number of instances of bot.

For example if my method for unitCreated is

Code: Select all

@Override
	public int unitCreated(Unit unit, Unit builder) {
		this.log.info("Unit finished:");
		return 0;
	}
and I had 4 instances of my bot, then log-team-0.txt would have the message "Unit finished" 4 times, log-team-1.txt would have the message 3 times, team 2, 2 times etc

So, my question is, is this expected? Do I need to simply test the incoming parameter values for null and deal with accordingly or have I set something up incorrectly?

I think before the pureInt change, you used a factory to instantiate a new instance of the bot, but that no longer seems to be the case.

Any help getting me on the right footing is greatly appreciated.

Hang
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: A threading issue?

Post by hoijui »

hangfire
Posts: 14
Joined: 06 Nov 2010, 08:31

Re: A threading issue?

Post by hangfire »

Phew, thought I was going a bit nuts.
Thanks, i'll handle it with some strategically placed try catch statements.
Post Reply

Return to “AI”