Page 1 of 1

Possible Artillery Group AI?

Posted: 06 Nov 2006, 23:51
by FLOZi
The idea being that you have some scout unit in the group, which when it gets an enemy in its LOS or weapon range, the arty units in the group will fire on it if they are in range, or if they are above a certain limit of mobility, move into firing range.

Possible?

Posted: 07 Nov 2006, 00:00
by AF
Write it out in pseudo code for us =p

Posted: 07 Nov 2006, 01:03
by FLOZi
well, the problem is i don't know whats possible with the interface :|

the steps required would be:

1. determine which units in the group were a scout or artillery unit
2. determine the speed of the artillery units (i.e. which are self propelled and which are 'static' (whether they be a building or a very slow mobile unit)
3. search for targets within LOS or weapon range of the scout(s)
4. order all the arty units in the group to fire at said targets when they appear, if they are in range
5. move mobile artillery into range and order them to fire

Posted: 07 Nov 2006, 02:56
by MadRat
It would be smarter to use two AI groups in unison, one to scout and draw out human controlled units and a second group of artillery to bushwhack them.

Posted: 07 Nov 2006, 14:14
by AF
Now take that pseudo code and make it more detailed using primitive orders such as move attack change trajectory, and use TDF tags from the unit fbis aswell.

Put them all under these headers, here's something to start you off.

Code: Select all

list of unit id's of artillery
list of unit id's of scouters/bait
other arbitrary values to control things

Unit (a) has finished command
    Assign a new command or wait

Unit (a) has been added to the group
    if artillery
        add (a) to artillery unit list
    else if scouter
        add (a) to scouter unit list
    else
        ignore and dont add it

Unit (a) has been removed from the group (destroyed maybe?)
    Remove unit

Init GroupAI has been created
    Do initial actions/calculations

Update, called 30 times a second.
    Check issue necessary orders, such as attack enemy if in range etc

true false Is This a scouter? (a)
    if its a scouter
        true
    else
        false

true false Is This artillery? (a)
    if it's artillery
        true
    else
        false
Just take some of the things in that and expand on them like take :

Check issue necessary orders, such as attack enemy if in range etc

And rewrite it into several lines describing how you would do that.

If you write something there that cant be done then we'll say and find a workaround, then at the end I'll take your pseudocode and translate it as best I can into C++.


But suffice to say writting out even a simplistic pseudocode of a groupAI will mean your chances of it actually being written rise astronomically.

Posted: 07 Nov 2006, 16:33
by FLOZi
Well first off I was just checking it wasn't completely beyond the realm of possibility :-)

edit: infact if you can send me in the direction of some group AI documentation I might take a crack at it myself, all I can find is the greenai article on the wiki

Posted: 07 Nov 2006, 20:29
by AF
Your best bet is to look at skirmish AIs and existing groupAI, as both use the same callback interface, and IGroupAI is the only different between the skirmish AIs and the groupAIs in terms of how the engine calls them.