How to know if java AI build order fail

How to know if java AI build order fail

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

Moderators: hoijui, Moderators

Post Reply
Bla
Posts: 79
Joined: 25 Feb 2013, 14:44

How to know if java AI build order fail

Post by Bla »

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?
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: How to know if java AI build order fail

Post by lamer »

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.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: How to know if java AI build order fail

Post by Anarchid »

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.
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: How to know if java AI build order fail

Post by 8611 »

As for events, the only related looking one I found was:
unitMoveFailed
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)
However, the description does not mention failed buildorders.
lamer
Posts: 153
Joined: 08 Mar 2014, 23:13

Re: How to know if java AI build order fail

Post by lamer »

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.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: How to know if java AI build order fail

Post by Anarchid »

If your bot plays ZK you can teach it to terraform.

Make the whole map flat, then play it! :D
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: How to know if java AI build order fail

Post by 8611 »

Either units run like mad in circles and UnitMoveFailed with UnitIdle never invoked
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)
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.
Bla
Posts: 79
Joined: 25 Feb 2013, 14:44

Re: How to know if java AI build order fail

Post by Bla »

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...
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Re: How to know if java AI build order fail

Post by PauloMorfeo »

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()".
Post Reply

Return to “AI”