How to handle units getting stuck?
Posted: 21 Apr 2012, 10:42
I created a Skirmish AI that plays BA for my thesis. I'm pretty much done and quite happy with it except for one issue. Every few games or so the commander will get stuck on a solar panel flap and just keeping 'bouncing' into it forever. This kills the game. I need to run several hundred games to collect data for my experiments, so preventing the commander from getting stuck would really help.
There are many other situations of units getting stuck (for example, in wreckage), and I'd love to fix the problem. But I understand it is pathing related and likely the only way I'll find a good solution is to rewrite the pathinding myself or wait for the new QTPFS to be finished.
But I need to graduate in June, so rewritting the pathing is not an option. I would be happy just to add some code to my agent to detect when the commander is stuck and adjust. I only give the commander 2 commands. Build and guard (specifically, guard a factory to help construct units faster).
For the 'build' commands, I can track the commanders position, the frame the build command was given, and if the commander started building yet (via unit_created event). During update events, I can check (say every 120 frames--4 seconds) if the commander hasn't started building yet, did he at least make some progress in moving from the previous position? If not, issue a new command.
For the 'guard' commands, I'm not sure what to do. I can track the commanders position, and every 120 frames, see if he make movement progress from the last update, but obviously, he will stop when he gets close enough to the factory to use his nano spray. I don't know how to detect when the commander is actually 'helping' the factory to construct units (in other words, that he is stationary because he arrived close enough to the factory and not because he is stuck on a solar panel).
What do you think is the best way to detect when the commander is really stuck? Also, is there a setting in spring to disable wreckage?
Thanks for your help!
There are many other situations of units getting stuck (for example, in wreckage), and I'd love to fix the problem. But I understand it is pathing related and likely the only way I'll find a good solution is to rewrite the pathinding myself or wait for the new QTPFS to be finished.
But I need to graduate in June, so rewritting the pathing is not an option. I would be happy just to add some code to my agent to detect when the commander is stuck and adjust. I only give the commander 2 commands. Build and guard (specifically, guard a factory to help construct units faster).
For the 'build' commands, I can track the commanders position, the frame the build command was given, and if the commander started building yet (via unit_created event). During update events, I can check (say every 120 frames--4 seconds) if the commander hasn't started building yet, did he at least make some progress in moving from the previous position? If not, issue a new command.
For the 'guard' commands, I'm not sure what to do. I can track the commanders position, and every 120 frames, see if he make movement progress from the last update, but obviously, he will stop when he gets close enough to the factory to use his nano spray. I don't know how to detect when the commander is actually 'helping' the factory to construct units (in other words, that he is stationary because he arrived close enough to the factory and not because he is stuck on a solar panel).
What do you think is the best way to detect when the commander is really stuck? Also, is there a setting in spring to disable wreckage?
Thanks for your help!