Currently the AI interface (at least java, but I suspect it isn't much different for the others) sucks horribly when it comes to teams. There are callins for enemyCreated, enemyFinished, enemyDestroyed etc, but none for allies (and the normal unitCreated etc callins don't apply to allies). It's also currently difficult to tell whether the AI has allies or whether it's alone.
Given that bots are very frequently expected to play on teams (ie coop vs ai games) it's kind of important that programming them to do so shouldn't be extra tedious. It's also extremely inefficient to have a bot sort through every allied unit just to find out if an ally has some unit x or not, or some unit near position x or not (as in no we don't need more static defenses here).
Better Teams Interface for AI
Moderator: Moderators
Re: Better Teams Interface for AI
Help clean it up.
Re: Better Teams Interface for AI
Hm, well it uses some weird iterator stuff over the ais that I don't really understand but was more or less able to work around.
So far I added the new allyevents to the following files:
AISEvents.h
SkirmishAIWrapper.h/.cpp
EngineOutHandler.h/.cpp
as well as shifted around the defs used in EngineOut a bit to clean them up and to include a new def for allyevents (ie, send allyevents to allies of team x but not to team x).
Is there anything else that I need to change for this to work properly with non-cpp interfaces? I didn't find anything particularly intelligible regarding how those are generated.
So far I added the new allyevents to the following files:
AISEvents.h
SkirmishAIWrapper.h/.cpp
EngineOutHandler.h/.cpp
as well as shifted around the defs used in EngineOut a bit to clean them up and to include a new def for allyevents (ie, send allyevents to allies of team x but not to team x).
Is there anything else that I need to change for this to work properly with non-cpp interfaces? I didn't find anything particularly intelligible regarding how those are generated.
Re: Better Teams Interface for AI
awk scripts are responsible for generation of newOO wrappers (for any language). Search for *.awk inside spring/AI/.
As long as you followed naming conventions with some specific comments new events should be autogenerated.
Don't forget to test it!
As long as you followed naming conventions with some specific comments new events should be autogenerated.
Don't forget to test it!
Re: Better Teams Interface for AI
I have concerns about ongoing work. Developed implementation:
a) Add new Ally(Created|Finished|Destroyed|Damaged) events.
I think it brings inconsistency: Unit(Given|Captured) is already sent to allies.
My opinion about proper implementation:
b) New Ally(Created|Finished|Destroyed|Damaged) events and decoupling Ally(Given|Captured) from Unit(Given|Captured).
c) Use existing Unit(Created|Finished|Destroyed|Damaged|Given|Captured) and send them to whole AllyTeam, add teamId param into those event structs, and fix few official legacy AIs (ignore event if event.teamId != ourTeamId).
I'd prefer (c).
HALP! What option is better? Other opinions/suggestions/options?
a) Add new Ally(Created|Finished|Destroyed|Damaged) events.
I think it brings inconsistency: Unit(Given|Captured) is already sent to allies.
My opinion about proper implementation:
b) New Ally(Created|Finished|Destroyed|Damaged) events and decoupling Ally(Given|Captured) from Unit(Given|Captured).
c) Use existing Unit(Created|Finished|Destroyed|Damaged|Given|Captured) and send them to whole AllyTeam, add teamId param into those event structs, and fix few official legacy AIs (ignore event if event.teamId != ourTeamId).
I'd prefer (c).
HALP! What option is better? Other opinions/suggestions/options?
Re: Better Teams Interface for AI
I'd do:
d) Use existing Unit(Created|Finished|Destroyed|Damaged|Given|Captured) and send them to whole AllyTeam, and fix few official legacy AIs (ignore event if callback.GetUnitTeamID(teamId) != ourTeamId). (don't add extra params)
or e) Use existing Unit(Created|Finished|Destroyed|Damaged|Given|Captured) and send them to whole AllyTeam, and add all the params to match the Lua callins, e.g. in the case of UnitCreated it would be (unitID, unitDefID, unitTeam, builderID), do the filtering as in c)
d) Use existing Unit(Created|Finished|Destroyed|Damaged|Given|Captured) and send them to whole AllyTeam, and fix few official legacy AIs (ignore event if callback.GetUnitTeamID(teamId) != ourTeamId). (don't add extra params)
or e) Use existing Unit(Created|Finished|Destroyed|Damaged|Given|Captured) and send them to whole AllyTeam, and add all the params to match the Lua callins, e.g. in the case of UnitCreated it would be (unitID, unitDefID, unitTeam, builderID), do the filtering as in c)