How to know if java AI build order fail
Moderators: hoijui, Moderators
How to know if java AI build order fail
How can I tell if one of my build orders fail if I'm making a java AI? Like if one of my builders tries to make a mex on top of a factory, will there be an event called?
Re: How to know if java AI build order fail
My AI relies on Idle event. If unit is idle and has build-task assigned and no build-target (e.g. building is not started yet), then its possible build order fail. Then just re-run FindBuildSite for new location.
Don't know if there is other options except checking it manually.
Don't know if there is other options except checking it manually.
Re: How to know if java AI build order fail
Sometimes UnitIdle fires when unit just switches between orders for some reason, so in ZKGBAI i ended up using command queue size to double-check against AI's internal intentions (not sent as orders).
And sometimes command queue will sit at nonzero length with no unitIdle firing and the unit doing nothing, so there's also a routine to look out for that.
And sometimes command queue will sit at nonzero length with no unitIdle firing and the unit doing nothing, so there's also a routine to look out for that.
Re: How to know if java AI build order fail
As for events, the only related looking one I found was:
unitMoveFailed
unitMoveFailed
However, the description does not mention failed buildorders.This AI event is sent when a unit received a move command and is not able to fullfill it. Reasons for this are: - The unit is not able to move - The path to the target location is blocked - The unit can not move on the terain of the target location (for example, the target is on land, and the unit is a ship)
Re: How to know if java AI build order fail
UnitMoveFailed unfortunatly works really rarely. Either units run like mad in circles and UnitMoveFailed with UnitIdle never invoked, or UnitMoveFailed beeing spammed because unit was pushed in unpassable place.
I think i'll add fail counter and selfd such units, or use air transport if its available.
I think i'll add fail counter and selfd such units, or use air transport if its available.
Re: How to know if java AI build order fail
If your bot plays ZK you can teach it to terraform.
Make the whole map flat, then play it! :D
Make the whole map flat, then play it! :D
Re: How to know if java AI build order fail
Yes, units can be moving but still never reach their target. (Sometimes units get near the target on path-A but suddendly path-B starts to look more attractive to them. And so they endlessly go endlessly go back&forth between two paths. Rare, but happens)Either units run like mad in circles and UnitMoveFailed with UnitIdle never invoked
Maybe have some timelimit ( roughly approximated on distance?) and if the construction is still not started after that then consider it failed and try again elsewhere.
Re: How to know if java AI build order fail
Hm, sorry I didn't get to replying sooner.
unitIdle(Unit unit) sounds like the best way, only the downside is that the unit returned doesn't have any commands in its list, so you can't tell what it's failed build order was, or where it tried building...
unitIdle(Unit unit) sounds like the best way, only the downside is that the unit returned doesn't have any commands in its list, so you can't tell what it's failed build order was, or where it tried building...
- PauloMorfeo
- Posts: 2004
- Joined: 15 Dec 2004, 20:53
Re: How to know if java AI build order fail
You can keep track of what your builder was trying to build. Ex: it was trying to build a Mex at (25; 73).
Whenever you want to check if it succeeded (ex: after it goes idle), you can sweep all your units to see if you one of them is a Mex at (25; 73).
This is just a work-around, of course...
It's a shame that there's not a "OrderCanceled()" event just like there is a "unitMoveFailed()".
Whenever you want to check if it succeeded (ex: after it goes idle), you can sweep all your units to see if you one of them is a Mex at (25; 73).
This is just a work-around, of course...
It's a shame that there's not a "OrderCanceled()" event just like there is a "unitMoveFailed()".