Global Ai interface is here! Should anything be changed?

Global Ai interface is here! Should anything be changed?

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

Moderators: hoijui, Moderators

alik83
Posts: 82
Joined: 08 Sep 2004, 15:32

Global Ai interface is here! Should anything be changed?

Post 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 :-)
SJ
Posts: 618
Joined: 13 Aug 2004, 17:13

Post 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.
alik83
Posts: 82
Joined: 08 Sep 2004, 15:32

Some functions needed...

Post 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...
SJ
Posts: 618
Joined: 13 Aug 2004, 17:13

Post 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.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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*
User avatar
Triaxx2
Posts: 422
Joined: 29 Aug 2004, 22:24

Post by Triaxx2 »

Something similar to the Flare function from Age of Empires?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
User avatar
Triaxx2
Posts: 422
Joined: 29 Aug 2004, 22:24

Post 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.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
alik83
Posts: 82
Joined: 08 Sep 2004, 15:32

I wonder...

Post 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 ;)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post 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...
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post 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.
SJ
Posts: 618
Joined: 13 Aug 2004, 17:13

Post 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.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post 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?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post 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.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post 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.
SJ
Posts: 618
Joined: 13 Aug 2004, 17:13

Post 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.
Post Reply

Return to “AI”