Home   Help Search Login Register  

Author Topic: Scripting: Advanced AI skill improvement  (Read 12438 times)

0 Members and 1 Guest are viewing this topic.

Komuna

  • Guest
Scripting: Advanced AI skill improvement
« on: 30 Oct 2003, 14:38:28 »
Exactly. I want them accurate, clean, smart and deadly.

I'm sick of seeing the AI acting like dummies, eventhough I play in "Veteran - SuperAI" mode.

So, I'm asking your OFP brains to sugest ways of making the AI smarter, by posting code and editing methods in this thread.

Note: You don't need to read the whole post, just a few lines to understand the main parameters.

Main objectives:

#Edit
I'll be adding new objectives as they come up. Last modifications: 10th and 11th objectives
#Edit

1 - Use a single waypoint for the whole path, which position can be updated with setWPPos. The waypoint's type should satisfy the combat conditions. Therefore, it's type shall be changed unsing the triggerSwitch method.

2 - In combat, the AI units shall engage at will without getting more than 60 meters away from their leader. If the leader orders one grunt to engage, he should be compeled to fall back into formation if he gets too far. Knowing if he's being ordered to engage can be achieved through unitReady.

3 - In combat, the AI's behaviour should be set according the proximity of the enemy, the terrain level and obstacles, the weapons in use, etc.

4 - In combat, the machine gunner stays close to the leader, usualy behind an obstacle and laid down. He's covered by a crouched grenadier, unless the situation compels him to lay down.

5 - Behind terrain elevations, while moving, the AI should low his head (by laying down) if he knows about the enemy presence. Besides, such thing will happen everytime there's a direct contact and there are some hidings nearby. Otherwise, the Ai shall keep on his foot and move quicly, or I'll kill him easily 8).

6 - There should be designated cover position (Forests, Rocks, Bushes), so that in combat eminence, the AI moves stealthily along those concealments - in order to increase realism.

7 - When facing tanks and APC's, the AI runs away to a safer point (special designated cover positions - Forests and between rocks) and the AntiAromor weapon specialist gets in position to engage the enemy. If there's no AA specialist, then run away and join a stronger force should be the solution.

8 - When contacting snipers, the AI shall move quicly to a safe point, get covered, deny engagement and proceed with a clever trap for the sniper by moving stealthily towards him, if they know his position. The snipers never stay at the same position.

9 - The AI shall be able to form small teams (two by two) within the group and keep close in urban combats.

10 - When disembarking from an APC (Exempli Gratia: BTR80), the AI should do it from the oposite side to the enemy, to guarantee safety, and move away from the APC, towards a safe position, to avoid being catched by its probable destruction.

11 - The AI shall not cross in front of their mates, while they're firing, to avoid stupid killings (added from macguba's post).

Surely I'm missing lots of parameters for the AI's better behaviour; that's why I'm asking you for help. But don't forget the code! ;)


Some hints on editing:

I've noticed that the AI behaves cleverer when they have to follow "Guard" and "Sentry" waypoints in Stealth/Combat mode and engaging at will. They hide, take better ways to engage the enemy and act more realisticly (not moving along into a perfectly simetric formation ;D).
However, they still fail most of the times. For example, in real life a leader would never order a single soldier to engage the enemy 200m away, unless he was nuts. They would do it in teams and would take the safest path, not the shortest one.

I'll be waiting for your sugestions. Once I've gathered the main code procedures, I'll make an AI improvement script.
« Last Edit: 31 Oct 2003, 15:10:11 by Komuna »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Scripting: Advanced AI skill improvement
« Reply #1 on: 30 Oct 2003, 15:08:40 »
Well beyond my knowledge to help, but if an improved AI script comes to pass - and I hope it does - then one little gem would be to prevent friendly loons from crossing in front of me when I'm firing.    
Plenty of reviewed ArmA missions for you to play

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Scripting: Advanced AI skill improvement
« Reply #2 on: 30 Oct 2003, 15:18:20 »
i started workin on som AI improvin script ;D

got somin like AI coverin while da oders move (nd in teams  :o) nd things like dat

but i gave up after i noticed dat wen deytried 2 flank enemy wat dey realy did was 2 draw fire while da leader nd his MG took all da enemies down (so all team members dead xept da leader nd MGunner ::)) ;D

but deres 1 hard thing here  :-X interactin w/ obstacles nd things like dat is haaard - no good way 2 detect it unless its somin da player puts dere  :-\

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Spinor

  • Members
  • *
  • I'm a llama!
    • The chain of command
Re:Scripting: Advanced AI skill improvement
« Reply #3 on: 30 Oct 2003, 16:55:10 »
Such a AI skill improvement script (or probably set of scripts) would be extremely useful.
The main problem of writing it would not only be to create a proper AI (always difficult),
but also to get the necessary information from OFP, namely the enemies positions
and the terrain features (location of trees, height information).
Another problem is the interference from the standard OFP AI. In general one should exploit
standard OFP AI wherever possible and only interfere where necessary.

Lacking some further ideas, I'll try to comment on the points you made (and no, no code yet  ;D):

Quote
2 - In combat, the AI units shall engage at will without getting more than 60 meters away from their leader. If the
leader orders one grunt to engage, he should be compeled to fall back into formation if he gets too far. Knowing if
he's being ordered to engage can be achieved through unitReady.
That should be fairly easy to achieve. One simply has to continually check the distance
to the leader. One should avoid too clear cut and "obviously scripted" behaviour, though, e.g.
that a unit immediately returns to the leader when reaching 60 meters. At first it could only
stop and seek cover and then return after some time .

Quote
3 - In combat, the AI's behaviour should be set according the proximity of the enemy, the terrain level and obstacles,
the weapons in use, etc.
One nice thing here could be different types of movements, i.e. bounding overwatch etc.

Quote
4 - In combat, the machine gunner stays close to the leader, usualy behind an obstacle and laid down. He's covered
by a crouched grenadier, unless the situation compels him to lay down.
Again, this shouldn't be too difficult either at it is easily definable. The biggest problem would be
to select position (behind obstacle? or terrain elevation? which one?).

Quote
7 - When facing tanks and APC's, the AI runs away to a safer point (special designated cover positions - Forests
and between rocks) and the AntiAromor weapon specialist gets in position to engage the enemy. If there's no AA
specialist, then run away and join a stronger force should be the solution.
It would be great (but even more challenging) if the AI script could handle different group types, e.g.
infantry squads, armor platoons, etc. To handle all the different situations, one could assign
different threat values to the groups according to their type. Threat values could be:
[AntiPersonnel, AntiArmor, AntiAir]
For example, an inf squad without AT or AA capability could have:
[5,0,0]
whereas an M1 tank platoon might have:
[10,20,5]

The decision to engage/hold/run away could then be based on comparing ones
own threat values with the one of the enemy (much like oldfashioned strategy games)


Quote
9 - The AI shall be able to form small teams (two by two) within the group and keep close in urban combats.
Could be achieved by using the follow command properly, and maybe in conjuction with the
formLeader command. AFAIK, it should be possible to have subformations within a group already.
Having such teams would even ease the task to write the AI (or at least reduce the CPU strain), as
one does not have to take into account all units but only the teams:
-Teams are controlled by improved AI
-Units within teams by standard OFP AI

A general programming scheme for an improved AI could be to introduce basic urges for a unit,
which have to be fulfilled concurrently. For example, a unit might have the "Stay close to leader"
and the "Stay close to cover" urge. Both urges get greater the larger the distance is (either
to the leader or the nearest cover). The mathematical task would then be to move the unit such the
sum of all urges is minimized.
The advantage of such scheme would be that it is fairly easy to create the basic urges,
but when combining them one could get very interesting behaviour (although I can't give you
a guarantee for that  ;D)

Unnamed

  • Guest
Re:Scripting: Advanced AI skill improvement
« Reply #4 on: 30 Oct 2003, 19:50:34 »
It would be good to bring all the AI scripts together.

I'm interested in how you envisage combining all the different elements and delivering them to the mission designer? Things like are you looking to track all the units in the game or just those for specific tasks e.t.c

Cant help thinking the Nueral Net code used by the COC artillery could be useful for this kind of thing.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Scripting: Advanced AI skill improvement
« Reply #5 on: 31 Oct 2003, 07:42:25 »
A few scattered replies:

Quote
6 - There should be designated cover position (Forests, Rocks, Bushes), so that in combat eminence, the AI moves stealthily along those concealments - in order to increase realism.

Here is an easy way to do this: this setbehaviour "COMBAT" or this setbehaviour "STEALTH". Those commands make the AI stick to covered positions, such as trees and bushes.

  Unfortunately, (AFAIK) there is no way to find rocks, bushes, trees, et. al with the "nearestobject" command. That is what has stopped me from doing some various AI scripts. The only form of cover that I could refer to was stuff that the editor placed. If somebody knows a way to get around this, I would love to hear it, because it sure would open up some doors.


Quote
7 - When facing tanks and APC's, the AI runs away to a safer point (special designated cover positions - Forests and between rocks) and the AntiAromor weapon specialist gets in position to engage the enemy. If there's no AA specialist, then run away and join a stronger force should be the solution.

  I believe there are some scripts out there already that will do this, such as Toadlife's group link script or Bremmer's AI script.


Quote
8 - When contacting snipers, the AI shall move quicly to a safe point, get covered, deny engagement and proceed with a clever trap for the sniper by moving stealthily towards him, if they know his position. The snipers never stay at the same position.

  Now this is something that a lot of missions could use. Way too often when playing a mission I can just sit back and take out a whole base with my m21 without anyone going after me. This problem can, of course, be fixed if the mission maker would just take some time to put a few triggers and waypoints down, but unfortunately most do not.


Quote
Another problem is the interference from the standard OFP AI. In general one should exploit standard OFP AI wherever possible and only interfere where necessary.

  Actually you can get rid of most of the AI with this command: this disableAI "TARGET". This basically eliminates the AI's programmed response to enemy fire. If you use this command, instead of running out and engaging the enemy, the AI will stay where they are, unless otherwise ordered to move (with a domove command).


Quote
got somin like AI coverin while da oders move (nd in teams  ) nd things like dat

but i gave up after i noticed dat wen deytried 2 flank enemy wat dey realy did was 2 draw fire while da leader nd his MG took all da enemies down (so all team members dead xept da leader nd MGunner )


  The biggest problem with OFP (and the biggest thing keeping it from becoming realistic) is the lack of micro-terrain. By this I mean the small little dips and bumps in the ground, and the little bushes or tall grass, and so on. Basically, the terrain is too flat and barren. I know OFP does a good job handling lots of bushes and trees at once, and the terrain often looks pretty well vegitated. But take a look outside and you will see all sorts of little places to lay down and hide in here and there.

  Basically, the reason why "covering fire" is of very limited use in OFP is because there is so very little cover. There is no way for a unit who is prone in OFP's land to get any more covered and protected. In real life, however, unless you are in the most flat and barren of landscapes, you can always lay down a little lower, or move a short distance first, and take better cover. But in OFP, since there is nowhere to take cover, there is no reason to take cover. And if no one takes cover, there can be no such thing as "covering fire" (bullets which are meant to get the enemy to hunker down, not to kill him): it's the same thing as shooting to kill.
   Of course there can be exceptions to this, but usually that only will occur when a mission designer specifically places units in defensive positions. That calls for it's own script, IMHO.


Quote
It would be good to bring all the AI scripts together.

Okay, now my main reply:

  There seems to be this desire to create a "one-size fits all" AI script. I guess the goal is to make one script that can be implemented in only a couple lines that will completely overhaul the AI, and will work in every situation for every mission. I don't see this as the way to go. It should be up to the mission maker to tailor the enemy's "AI" to suit his specific mission.
  For example, in a 'Nam mission I am currently making, I wanted to improve the enemy AI, so I thought I would use Bremmer's AI script. It is an impressive script, but I found many problems that made it unsuitable for my mission. First off, it makes the enemies "talk" to each other using the ingame voices, which are russian, and my baddies are Vietnamese. That doesn't sound right, and so I proceeded to try to edit out that part of the script. Okay, no big deal though. Next, I didn't want most of my enemy's calling for support groups to come help them, since I didn't think that my Vietcong guerillas really would have the ability to call backup to their position like that. And even for times they could, the only American group anyone would encouter was going to be the player squad, so I could just as easily use a simple "detected" trigger and have a support group move to the player's location.
  I really wanted the enemies to call artillery on the player's group, like Bremmer's script does. However, I didn't like the specifics of his artillery barrage (shell type, impact area, amount of shells, etc), so I found myself editing that part of the script to suit my needs. But there were so many things I wanted to change, it ended up being easier to write my own script.
  I also liked how the enemies will try to retreat with Bremmer's script, but I also wanted them to surrender at times instead of retreating. Again, it ended up being easier to write my own script for this.

  Instead of trying to make the script that always works for everybody, we should focus on making AI scripts that fulfill one specific function, such as a script to call for backup, one to engage enemy snipers, etc. Then it should be up to the mission designer to "plug in" which script(s) fit best within his mission, and to toggle the parameters of the script to suit his needs. The main thing to watch out for in this model, though, is to make sure multiple scripts don't interfere with each other. I think a sort of open-ended AI script standard would be nice. Basically, scripters could create small AI "snippets" to fulfull one specific need, and the standards would make sure that nobody's AI script interferes with the operation of another persons AI script.

  Whew! Sorry, that was longer than expected. Anyway, I hope you get my gist. I like AI scripts, but I think it should be up to the mission designer to get the "best fit" for his mission, not the scripter.

HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Spinor

  • Members
  • *
  • I'm a llama!
    • The chain of command
Re:Scripting: Advanced AI skill improvement
« Reply #6 on: 31 Oct 2003, 14:34:28 »
Quote
Cant help thinking the Nueral Net code used by the COC artillery could be useful for this kind of thing.
Quite right, at CoC we are looking into this  ;D. At CoC, we are actually more concerned
with inter-group-AI (how different groups work together to achieve a goal) than intra-group-AI,
but the same rules apply.
Denoir created a completely general Neural Net Module that can be used for all AI
tasks (and even non-AI tasks like the artillery).

Quote
Unfortunately, (AFAIK) there is no way to find rocks, bushes, trees, et. al with the "nearestobject" command. That is
what has stopped me from doing some various AI scripts. The only form of cover that I could refer to was stuff that
the editor placed. If somebody knows a way to get around this, I would love to hear it, because it sure would open up
some doors.
There is way, but a very nasty one. Essentially, you have to use nearestObject on a very fine grid,
say 2-5 meters in x- and y-direction. With this you can capture most objects (you'll miss those that
are closer placed than your search grid).
The main problem is only that bushes/trees/forests/roads do not have a object class. The only way to
differentiate them is to take their z-value:
roads: z = approx 0
bushes: z = approx 2
trees: z = approx 12
forests: z = approx 20
Using this approach I wrote an terrain sampler for CoC that creates a matrix array (100x100 elements,
one element corresponds to one terrain grid) containing data about the terrain. It works quite well, giving
a faithful representation of the terrain features like vegetation, roughness, etc.
For an improved group AI it won't be necessary to do it for the whole map but only in some
proximity of the group.

Quote
Actually you can get rid of most of the AI with this command: this disableAI "TARGET". This basically eliminates the
AI's programmed response to enemy fire. If you use this command, instead of running out and engaging the enemy,
the AI will stay where they are, unless otherwise ordered to move (with a domove command).
Doesn't this mean, though, that we would have to do our own "Target-AI"? Unfortunately, the AI
can't be enabled once disabled, so we are stuck with it.

Komuna

  • Guest
Re:Scripting: Advanced AI skill improvement
« Reply #7 on: 31 Oct 2003, 14:56:51 »
@Spinor & General Barron

Well, thanks alot for your posts! Keep improving the main idea!

Note: just avoid explaining how to do the scripts concerning my posts, as most of my objectives I already know how to code. ;)

@Community

Hmm... Don't think I'm gonna make a single and easy-to-use script! It will be for advanced users only!
Notice that most the AI settings, according the several scripts we'll put at dispose, will have to be configured by the editor him-self! For example, the safe positions and random safe paths - these last shall be "choosed" by the AI regarding the enemy's position.


Oh! And... Excuse my ignorance. ::) What does "AFAIK" mean?



#Edit

1:

The most important of these scripts will be the one concerning the AI's behaviour according the terrain!

Several times I've seen AI enemies coming after me from very bad positions and through the shortest path, being an easy target. So, I want them clever and deceiving!

I've made one similar script, once, which fulfils the need of getting the terrain elevation, etc. However, it causes too much lag, and besides, Spinor mentioned a terrain monitor script (right?) which I don't know and that might be very usefull.


2:

Answering Spinor, the enemy position monitoring is easy. Lets see: If you don't know the enemy's position, yet a small reference, then you take the theoricaly most safe path. Yet if you know were the enemy is (countEnemy and knowsAbout association, 'forEach' leader), then you behave differently. It's a question of realism.


In conclusion, the enemy position checker and terrain checker are theoricaly solved - now, we need scripts. However, one of the most difficult to solve will be the obtacle checker (very important for concealment/covering).
In my opinion, if such objective gets too hard to achieve, then there should be designated safe locations (as I've already mentioned) and study the best behaviour conjuctions (waypoint type, combat behaviour, engagement setting, speed) we might combine, so that the AI covers and positionates strategicaly at those locations.
« Last Edit: 31 Oct 2003, 15:25:23 by Komuna »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Scripting: Advanced AI skill improvement
« Reply #8 on: 31 Oct 2003, 16:58:13 »
As Far As I Know
Plenty of reviewed ArmA missions for you to play

Offline Spinor

  • Members
  • *
  • I'm a llama!
    • The chain of command
Re:Scripting: Advanced AI skill improvement
« Reply #9 on: 31 Oct 2003, 17:12:08 »
Quote
Oh! And... Excuse my ignorance. What does "AFAIK" mean?
AFAIK, as far as I know ;)

Quote
I've made one similar script, once, which fulfils the need of getting the terrain elevation, etc. However, it causes too
much lag, and besides, Spinor mentioned a terrain monitor script (right?) which I don't know and that might be very
usefull.
I have to say though, that it also lags as a lot of nearestObject calls have to be done
to get a reasonable faithful terrain representation. I don't think this is really a problem
because we don't have to actually "monitor" the terrain all the time as it is mastly static.
One can make once in a while a sample of the terrain surrounding our group, store the
result, and access it from memory.

Quote
Answering Spinor, the enemy position monitoring is easy. Lets see: If you don't know the enemy's position, yet a
small reference, then you take the theoricaly most safe path. Yet if you know were the enemy is (countEnemy and
knowsAbout association, 'forEach' leader), then you behave differently. It's a question of realism.
In principle, monitoring the enemy is not too difficult, but it can also put some nosty strain on the CPU, because
unlike to terrain sampling it must be done regularly. Also, we not only need the positions
but also the strength/type/ability.

Quote
In conclusion, the enemy position checker and terrain checker are theoricaly solved - now, we need scripts. However,
one of the most difficult to solve will be the obtacle checker (very important for concealment/covering).
I would say that the obstacle checker is also solved theoretically. It should best be combined with the
elevation checker to give a terrain sampler.

Unnamed

  • Guest
Re:Scripting: Advanced AI skill improvement
« Reply #10 on: 31 Oct 2003, 17:55:04 »
Quote
Quite right, at CoC we are looking into this  . At CoC, we are actually more concerned
with inter-group-AI (how different groups work together to achieve a goal) than intra-group-AI,
but the same rules apply.

Yeah, different nets for the different layers.

Quote
Denoir created a completely general Neural Net Module that can be used for all AI
tasks (and even non-AI tasks like the artillery).

I will have to prise it out of the Artillery scripts, as the zip file in the COC downloads section is empty :(

Quote
In principle, monitoring the enemy is not too difficult, but it can also put some nosty strain on the CPU, because
unlike to terrain sampling it must be done regularly. Also, we not only need the positions
but also the strength/type/ability.

If only have to monitor what group leaders are present, anything else could be picked up at the start or after contact has been made. It just requires lots of detect triggers, for those groups who can report.

Offline Spinor

  • Members
  • *
  • I'm a llama!
    • The chain of command
Re:Scripting: Advanced AI skill improvement
« Reply #11 on: 31 Oct 2003, 18:14:05 »
Quote
I will have to prise it out of the Artillery scripts, as the zip file in the COC downloads section is empty
I wasn't aware of that, I'll check with denoir if he can put it back.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Scripting: Advanced AI skill improvement
« Reply #12 on: 31 Oct 2003, 21:37:56 »
Ooooh and AI thread! ;D You AI nuts might wanna check this, this, and this out.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Scripting: Advanced AI skill improvement
« Reply #13 on: 31 Oct 2003, 22:30:02 »
Quote
The main problem is only that bushes/trees/forests/roads do not have a object class. The only way to
differentiate them is to take their z-value:
roads: z = approx 0
bushes: z = approx 2
trees: z = approx 12
forests: z = approx 20
Using this approach I wrote an terrain sampler for CoC that creates a matrix array (100x100 elements,
one element corresponds to one terrain grid) containing data about the terrain. It works quite well, giving
a faithful representation of the terrain features like vegetation, roughness, etc

Spinor, could you please post this script?! This is EXACTLY what I have been wanting to be able to do for so long! I'd love to see this! I can think of so much to do with this!

*Salivates heavily*
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Scripting: Advanced AI skill improvement
« Reply #14 on: 02 Nov 2003, 17:42:59 »
If you don't mind, have a look into this thread:

http://www.ofpec.com/yabbse/index.php?board=6;action=display;threadid=13884

Waypoint SCRIPTED seems to fit perfect into your idea,
as you can have a mix of waypoints and scripts.
With a lil bit of tuning, you'll be able to easily switch thru
let's say: a sentry wapoint, or a guard and the scripted one  ;)

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted