Game hangs when new command makes SCV
Posts: 27
Joined: Fri May 20, 2011 12:34 pm

Game hangs when new command makes SCV

Postby TheBlueGnu » Sun Jul 31, 2011 7:13 am

Updated: 3 times

I'm using BWAPI 3.6 and I've got a problem I just can't find any cause for.

I've made code that goes through an array of bases (in an update method) which gets workers to make stuff at their base, harvest or make new bases.

The problem is that when I've made a command centre at a new base, and asked it to train a worker it crashes after the first is trained and another is just started.

If I don't ask it to train, and just output a message saying "command at base x wants to train" then it's all good - but workers are not made. I've outputed messages to see where it gets to before it hangs. The test ai module on unit create method finishes, but the messages in the update method (called once every 30 frames in the onframe method) don't display, although somehow a new worker gets trained...

The on frame method DOES get called after the on unit create method, but it seems 30 frames do not pass before it hangs.

Ignore attack and information manager, they don't do anything useful at the moment.

Base.h + cpp stores the command centre and workers assigned to make buildings at a base
BuildManager.h + cpp has the commands for actually making a building and getting location
BaseManager.h + cpp has the update and on unit create anmethod and all the stuff which looks at bases and gets them to do stuff.

TestAIModule.h + cpp is the ai module, stores a variable for base manager in .h and has the onunit create, on frame, on remove etc methods. The on frame calls an update method and the on create calls the equivalent method in base manager.

As far as I can tell it doesn't work for no reason. I just can't figure it out :S Please help!

Update: 1/8/2011
Put in a lot more comments and now sometimes it crashes when the command is just being made - or it fully builds, makes a scv then crashes. It is very odd.

I know that the game crashed before when 2 scvs tried to make a command at the new base at the same time (with one already being made) and a number of messages that SHOULD have been outputted before it crashed didn't. That is, it showed the message before the buildthis method was run for both other scv's, but not all the ones which are meant to show in the body of the buildthis method. It doesn't do that now I think, but the problem might be equally odd.

Update 2: 1/8/2011
I might have the cause of the problem. When the ai I made wants to make a command centre, after the first one it made, it heads to (in this case) happens to be the enemy base and dies. When an scv dies, the Unit* array position for the base it belonged too is set to NULL. I do this by passing "NULL" to the Unit* setter method for the base manager class.

I set it to null since I want to use the scv array position for that base again and I don't know what to do otherwise if a unit dies. Does anyone else think this might be the problem?

Update 3: 2/8/2011
Isn't that I think now. Don't know what though. Discovered the on unit destroy method wasn't doing stuff since I accidently put the code in the "is a replay" instead of "is not a replay" part of the if in test ai module. Having spent more time then is probably healthy on this, I can only conclude it doesn't work for no reason. Output print statements to the screen, the error happens after the second command is built, trained 1 worker and started another. In the on frame method in test ai module, it succesfully executes marine search and destroy and does the whole onframe method EXCEPT it skips the code which runs update() for base manager. It doesn't even go print statement then run method, the entire body of the frame % 30 if statement is skipped. I know the marine method worked as I put it in another if.

After the method is skipped for some reason it prints that the on frame method is over - THEN CRASHES. I have no idea why. I went over the body of the update method, and tried commenting stuff out, but no luck. It simply wants to crash...

Return to “BWAPI (wrappers in other languages / questions and announcements related to BWAPI itself)”

Who is online

Users browsing this forum: No registered users and 1 guest