Page 1 of 2

Global Ai interface is here! Should anything be changed?

Posted: 30 Jun 2005, 19:14
by alik83
Global Ai interface is available in CVS, look through the code and post your thoughts!

One thing I noticed is- there's no function in Callback to get positions of enemy radar blips.
There is only a function to get unit position given UnitID even if you have only radar to it, and old GetEnemyUnits() which gets enemy units in LOS I think, so no way to get unitIDs or positions of enemys in radar.

Also I wonder what exactly GlobalAIHandler file is for and should it be included to create GlobalAi dlls?
Why are functions such as UnitCreated(), UnitFinished(), UnitEnteredRadar() not in the GlobalAICallback file but in GlobalAIHandler file?

Well, no more questions for now, thank you ,SJ, for posting the interface :-)

Posted: 30 Jun 2005, 23:14
by SJ
Hm ack someone stole my subject :)

There is a GlobalAITest project in the root now that can be used as a base to create aidlls.

The only way to activate them at the moment is to use the globalai test script which will try to load the aidll/globalai/test.dll and use it for team1.

Since all the functions are untested except for the ones used in the testdll there is probably some errors still in there.

Some functions needed...

Posted: 01 Jul 2005, 09:23
by alik83
And SJ, those functions are really needed for GlobalAICallback(GroupAI too):
(I'm repeating myself, but as we say in Russia "repetition is the mother of study" ;))

1)Radar blips positions info

2)Get user input from chatbox - for helper functionality (to set some variables and behaviours for your AI during a game, give your AI specially defined commands)

3)Function to acess marker positions and names (also for helper) - so special commands could be given to AI
involving your markers (like attack from direction of this marker and so on)
Probably when drawing the markers you can put their central position, name in some set which can then
be accessed by AICallback (store only 1 point signed markers for ease).

4)(Harder to implement, so not high priority)Function to see whether there is enemy fire coming into a given map area (square) (like artillery or Nuke) for AI's units not to stand under fire.

More things would probably come up when implementing a full-featured AI...

Posted: 01 Jul 2005, 10:36
by SJ
1: You can already get pos for inradar units since you get a enemyenteredradar call everytime somone enters your radar...

2: Hm ok might be usefull

3: Later maybe, current global ai isnt really meant to interact with a user

4: Hm ok can look at that.

Posted: 01 Jul 2005, 11:12
by AF
3)Function to acess marker positions and names (also for helper) - so special commands could be given to AI
involving your markers (like attack from direction of this marker and so on)
Probably when drawing the markers you can put their central position, name in some set which can then
be accessed by AICallback (store only 1 point signed markers for ease).
Store the location as a variable and refer to it. If you need to itneract with the user, place a marker at the location and when a command is given nearby mvoe it to the marker location. For howto palce a amrker, there are numerous GUI drawing tools such as lines etc as used byd rawing markers ingame.


And CVS?!?!? I cant access that here?!?!?!?! It's bad enough with my net access crippled, oh well I shall have to spend time trying to get broadband working again *sits dismayed at router that sits too far away for wifi signal to reach*

Posted: 01 Jul 2005, 12:02
by Triaxx2
Something similar to the Flare function from Age of Empires?

Posted: 01 Jul 2005, 12:24
by AF
There is no reason why that can tbe done with GroupAI. Create a flare unit with fancy animations etc, tell the AI to draw a virtual flare unit (these are what the buildings look like before construction starts when they've been placed or are beign placed) then destroy the virtual flare unti after a few secs, perhaps make it spew smoke ro some other weapons fire so it's seen on the minimap, then place line markers where the flare was in some gneric shape such as a triangle or pentagon.

However I have yet to read through GlobalAI and know that GroupAI doesnt have the necessary key/mouse/GUI abilities necessary to start the process.

Posted: 01 Jul 2005, 12:54
by Triaxx2
Not quite what I meant. I'm talking about the ability to lay down a priority attack order to have allies attack every unit near a certain location.

Posted: 01 Jul 2005, 13:12
by AF
Ah, well thats something I've spoken about in several other threads. It needs the New GUI code fixing though.

Or a GroupAI could check to see if the target is a unit or terrain and if terrain it could be interpreted as a priority attack order as you described.

I wonder...

Posted: 05 Jul 2005, 13:56
by alik83
I wonder if SJ would want us (who want to program AIs) to write some simple AI from GlobalAITest to test out how the GlobalAI functions work and stuff...
I personaly would prefer to wait for SYs to write a simple AI which demonstrates all GlobalAi functions, how different orders are given and stuff like that. Probably they're already working on this...

And why not create basic helper AI functionality sooner, cause that's the part I'm most interested in ;)

Posted: 05 Jul 2005, 14:00
by AF
I think the testAI is all SJ will be doing for now unless eh changes the GlobalAI implementation.

Untill then it is us who'll be doing the coding with regards to globalAI.

Pity I cant do any coding in school.

Posted: 06 Jul 2005, 15:07
by jcnossen
I personaly would prefer to wait for SYs to write a simple AI which demonstrates all GlobalAi functions, how different orders are given and stuff like that. Probably they're already working on this...
Most if not all the functions from the callback are pretty self-explanatory. I've encountered one unexpected issue though: when you issue an order using GiveOrder(), the command is not directly visible through GetCurrentUnitCommands(). This means you have to mirror your given order to find out what your units are doing.
Anyway, you'll just have to dive in and start experimenting if you want something done...

Posted: 06 Jul 2005, 15:53
by jcnossen
And what I forgot:
Could it be possible to extend the UnitFinished() function to something like UnitFinished (int unit, int builderUnit)? At the moment there seems to be no way to find out if by which builder the finished unit was built.

Posted: 06 Jul 2005, 19:09
by SJ
The reason orders arent visible immidiatly is that they work just like a humans order meaning they have to go to the server first before they become "official".

It would be kind of hard to tell which unit built another one since several ones can work on it at once and the original builder might have died/moved to other tasks before its finished. And you will already get a UnitIdle call for the builder if the build command was the last command in its queue.

Posted: 06 Jul 2005, 20:32
by jcnossen
The thing is, I'd like to be able to add the new units to the same unit handler in the global AI internal code as the units who were building, so for example my recon management units are not stealing just-finished construction kbots from my resource management units.

I could use something like an extra parameter given by the building unit to the unit being built, maybe an extra element in Command::params ?
Could it be that the AI hint of the unit serves this purpose, and if not, could you explain what it does?

Posted: 06 Jul 2005, 20:33
by AF
yeah what does that do anyways?

zaphod do you mean say a unit in groupAI 1 builds a loada units, and those units are all in GroupAI 1 as a result? because if a unit under a groupAI is a construction unti, everythign it builds si added to the parent AI

Posted: 06 Jul 2005, 20:57
by jcnossen
zaphod do you mean say a unit in groupAI 1 builds a loada units, and those units are all in GroupAI 1 as a result? because if a unit under a groupAI is a construction unti, everythign it builds si added to the parent AI
Something like that yes, but I don't want to create a new groupAI dll for every bunch of units handled by the global AI, I would like units to store the unit id of the unit that started building.

At the moment, this would involve searching all the units for which UnitFinished was called for a position that matches the build-position of the builder unit. Hmmm, that's not even such a bad solution :)
IMO, the above method is still kindof a hack but I'll just use it for now.

Posted: 06 Jul 2005, 23:52
by AF
when a building construction is started I'm guessing that unit then exists with its UnitID, and continues to exist as it is untill its death even through contruction. Therefore you just note down soemwhere the unitID of what units are being built, then check them off when they've finished.

Posted: 07 Jul 2005, 01:48
by jcnossen
Problem was that you don't know the right unit ID with the right builder unit ID. Anyway problem is solved now, I use the position of the unit as hash index into hash_map, so it's pretty fast too.
This requires a fix for those unfinished units walking out of their plants though, as that would mean the wrong hash_map key is generated.

Posted: 07 Jul 2005, 18:33
by SJ
If you just check the pos at UnitCreated rather than UnitFinished it doesnt matter if they walk away. Beside I think its fixed now ?

AiHint was an integer representing what sort of unit it was in old spring, like 1000-1099 was defensive towers etc.