Jump to content
Sign in to follow this  
cartier90

How does the AI work ?

Recommended Posts

In a 'normal' FPS game, it is easy to see how a AI enemy might go about their day. They have a pre-defined path, and in ARMA vernacular 'cycle' between given points.

I am not au fait with the exact workings of how they detect the player but I guess line-of-sight calculations are done and if your 'visible' , a firefight ensues ( with usually fast reactions on the part of the AI ).

1 ) I am interested in how the AI in ARMA work, when confronted by a force , is the AI intelligent enough to react differently , to differing numbers of opposing troops and too different troop configurations ? ( spread out , or concentrated formation)

2 ) I am ignorant of how dynamic AI works, but in laymans terms, how does a AI enemy make its 'own' decisions without a structured pre-defined path ? -At any one time is consideration given to survivability over 'their' objective of killing you according to how the wider battle is going ?, or is it a little more straightforward, with the AI maintaining the same commitment throughout .

I am aware the AI can retreat - is this a random occurence or strictly down to percentage of their own forces killed.

I appreciate it is hard to break down the nuts and bolts of AI in laymans terms , but am fascinated at what goes on behind the scenes and what exactly I am up against in game..

..

Share this post


Link to post
Share on other sites

The AI doesn't really have a line of sight. Or they do, but it is heavily mixed with a system based on probability. You can hide behind a bush and remain unseen, but it would be taxing on the system for the AI to be constantly checking what it can and can't see with a LoS. I assume that the game keeps track of where everything is and performs the necessary checks once the list of factors likely to conceal you (stationary, prone, far away, near other object) dwindles. You can also see this system glitch sometimes when the game forgets that a hill is supposed to hide you. The AI can also 'see' you through a fence if you make too much noise, and they extrapolate your position if you run out of sight by assuming that your heading and speed remain constant.

In terms of combat, the AI will typically choose paths that have a lot of objects providing cover. They try to stay in formation and don't often change it. They know how to flank, suppress and cover their teammates in tandem. They don't really know how to defend, but they will peak around corners a lot. They like to lie down.

They have morale, and if you kill the officers and most of the squad, the survivors will hightail it. Sometimes you will see whole squads running from tanks into nearby woods.

But their modus operandi is really quite simple, even if the application is appallingly complex. See enemy, shoot enemy, assault or not. If so, use buddy system and try to flank, while the team leader picks targets and gives engage commands based on the most threatening or vulnerable enemy.

Share this post


Link to post
Share on other sites

This is, a very good question.

The first answers may be found by experimenting with the Editor.

My post will not give you the solution but may help you to calculate your awareness.:yay:

Share this post


Link to post
Share on other sites

What would really cap the game off would be greater speed to all decisions. In my eyes, the AI is great at what it does , its just the animations need to be that bit quicker. When shot at , they should pick themselves up from prone and scuttle off to cover immediately, rather then their slightly tardy movements at present.

What is the biggest barrier to improvements in AI in ARMA - CPU speed or programming? Programming a more human like intelligence is obviously vexing even the largest scientific institutions so perhaps until a breakthrough is reached, this is as good as it gets ?

Share this post


Link to post
Share on other sites

1) I'd say they react differently to specific types of ennemies (infantry, armor, etc...), not sure of the level of tweaking done based on size of the ennemy force.

2) There are predifined paths, somehow. 1st, there are roads, which have special properties for AI in vehicles, they will be preferred choice under some circumstances. Then there are path statically defined inside "models", ie every 3D objects added "on top" of the world, typically, houses, buildings. AI cannot get out of these paths, they are very constrained when inside buildings. In "normal" world, outside, they are free, and usually use 3D "bounding boxes" of objects to determine nearby cover and such. Then they will use their automated bounding overwatch movement algorithm to move to your position to kill you. Or, more precisely, the position they expect you to be.

They stop once a) you're dead, b) they lost you, c) they flee, which is trigerred by their own courage and the number of their comrades fallen around them

Share this post


Link to post
Share on other sites
What would really cap the game off would be greater speed to all decisions.

I'd say that requires merely a tweak, plus the fastest computer imaginable. I really have no idea how fast and effective the AI would be with perfect framerates, since I can't get about 30 without looking straight up at the sky.

Share this post


Link to post
Share on other sites

Maturin - I suspect that background scripts are the frame killers that just AI routines. I can put a lot of units together in the editor and have a scrap with high frames - campaign wise, bit of a slideshow at times....

Share this post


Link to post
Share on other sites
Maturin - I suspect that background scripts are the frame killers that just AI routines. I can put a lot of units together in the editor and have a scrap with high frames - campaign wise, bit of a slideshow at times....

You're not playing on a dual core laptop with a 512 videocard, I'm guessing.

But those scripts really do eat the frames, and to add insult to injury they are glitchy as well when things are choppy.

Share this post


Link to post
Share on other sites

No - my old laptop was oven like just surfing the net - dread to think what plastic melting temps are reached pushing ARMA OA around.

I do find the campaign, and a lot of what OFP / ARMA attempt to simulate as a little OTT at times, at least with present tech. I feel too much is simulated off screen - better performance could be reached with a penalty of less fidelity with a similar gameplay experience.

Share this post


Link to post
Share on other sites

You can see some of the higher level AI behavior if you study the AI FSMs, but a lot of it is still hardcoded in the engine. There are probably only a handful of people that can tell you exactly how they work, but some community members have actually produced some pretty interesting experiments. There are quite a few threads here with information so perhaps you could search for those.

Share this post


Link to post
Share on other sites
The AI doesn't really have a line of sight. Or they do, but it is heavily mixed with a system based on probability. .

This is really what Im trying to understand. I've always imagined there were primitive laser beams of LOS that factored along with many other variables (terrain stance of target/time of day/noise/etc...) that were really affected by which way the soldier's face was oriented.

So when you see a soldier turn his head left and you happen to be left -no laser beams of sight...?

Edit: I'm guessing the soldier's head orientation would just +/- the probability of being seen eh? Do any games use laser beams of LOS? I demand laser beams of LOS!!!

Edited by froggyluv

Share this post


Link to post
Share on other sites
This is really what Im trying to understand. I've always imagined there were primitive laser beams of LOS that factored along with many other variables (terrain stance of target/time of day/noise/etc...) that were really affected by which way the soldier's face was oriented.

So when you see a soldier turn his head left and you happen to be left -no laser beams of sight...?

AFAIK, that is correct, they also often tilt their head when they have unidentified objects at their edge of sight.

And i think probability is only used on grass which afaik is slightly

, however
have blocked the sight of the AI since forever, and since ArmA2 the actual blocking properties of plants(except grass) match the visible model much better.

*Note that that is recorded in ArmA1, everything seems to be much better tuned in ArmA2.

Edited by NeMeSiS

Share this post


Link to post
Share on other sites
AFAIK, that is correct, they also often tilt their head when they have unidentified objects at their edge of sight.

That is good to know and one of the things I've always likes about this series -enemies actually turning their heads and looking as opposed to an instant full body orientation upon alert.

Of course, sometimes they are too slow to orient when an obvious threat is detected -best would be to have random dice factor + skill level decide that.

Share this post


Link to post
Share on other sites

put 2 squads of opposing infantry in some woods and tell them to use danger movement on their waypoints. they will do a bounding overwatch and flank, albeit somewhat crudely. in missions where you have more than 4 guys in your team, using this system will allow your team to fight the war for you essentially and you just gotta lead them. im very impressed

Share this post


Link to post
Share on other sites
This is really what Im trying to understand. I've always imagined there were primitive laser beams of LOS that factored along with many other variables (terrain stance of target/time of day/noise/etc...) that were really affected by which way the soldier's face was oriented.

So when you see a soldier turn his head left and you happen to be left -no laser beams of sight...?

Edit: I'm guessing the soldier's head orientation would just +/- the probability of being seen eh? Do any games use laser beams of LOS? I demand laser beams of LOS!!!

Maybe corridor shooters with tiny levels and low numbers of AI can handle spotting solely with 'laser beams.' But imagine how prohibitively costly this would be in Arma's huge, cluttered environment.

But I tend to think that the Line of Sight only supplements the underlying probability system. A unit behind an object or behind the AI's back has 'protection' from being procedurally, mathematically spotted. But the engine knows that you are there, and the instant you make a move, it will check the line of sight and your foot will get shot off.

Share this post


Link to post
Share on other sites

The game always know where every unit in it is, so it can perform ray tracing LOS tests for vision with clutter modifiers and what have you, and it also can hear. I'm not sure what shape it would test the line of sight rays on, but they are probably bounding boxes or something. The AI also tells each other what it knows, and also radios in to some high command abstraction (not really talking about the warfare module) which will then issue orders and call support (I mean nearby units, not support like the module) if available. The game also keeps track of some percentage called 'knows about' for each unit that knows about some other unit, for each unit it 'knows about'. This behaviour can be seen in the game, especially when using lots of HUD features. If you target something, the progression of 'knows about' goes something like vehicle=>man=>enemy man=>enemy machine gunner as the unit gets more information about it. Also you might see the target box jump around a bit as your unit accumulates more accurate position information. Once you lose LOS, the AI predicts where it thinks the your target would be, given its last known position and vector. If you see a target box constantly jumping around behind a hill, I think you're being updated on what your character's AI 'knows about' the position of the unit you're tracking based on sound or some other factor. This happens a lot when you're tracking vehicles just over a ridge or behind a wall.

When the AI is choosing a path for itself, I think defines waypoints in 3d space based on certain rules and conditions, such as what its task is, what its alert state is, what the terrain looks like, what other obstacles are there, if there are roads present, what other units are in formation, etc. Of course, if you just put a bunch of units in the editor without a task, they just stand there... but they will start to fight once they 'know about' some enemy unit, and will attack based on the enemy force's composition and position.

Share this post


Link to post
Share on other sites

Amazing the amount that really goes on under the hood.

I'm not sure what shape it would test the line of sight rays on, but they are probably bounding boxes or something.

This fascinates me - I want more!

Share this post


Link to post
Share on other sites

ConstructorBoundingBox.jpg

It's probably not so extravagant as you might imagine. Bounding boxes, like bounding spheres, are just primitive shapes that define the extents of some 3d form. They provide a simple mathematical basis for things like finding how big an object is or something. I don't think they are like polygon geometry, but as to the exact nature of bounding objects, I can't say. Maybe the engine uses the geoLOD to do such visual calculations and not bounding shapes at all. The geoLOD for the soldier models are just this weird cylinder type shape, though. It doesn't resemble a soldier any more than a bounding shape would, except maybe its volume was carefully chosen for soldiers by a person.

Edited by Max Power

Share this post


Link to post
Share on other sites

Interesting. So basically the AI's rays orient from their head direction and a LOS check is probably given extremely often and what they detect as a human threat are actually the enemy model broken down into those boxes?

Going back to Maturin's post, would a LOS check on a smaller box aka "a foot" be harder for the AI to detect then say a larger torso box?

Edit: It appears you answered my question in that the soldiers probably have an overall detecion shape as opposed to broken down into individual bodyparts.

Share this post


Link to post
Share on other sites

I think maybe I came off more certain than I actually am. I don't know how the engine works, this is just how I think it works. I'm much, much more certain about the knowsabout stuff than I am about how the visual detection works. My guess for the bounding box was not a bunch of boxes, but just one box defining the maximum extents of the unit.

I have a foggy memory of seeing a video of OFP about what the AI 'sees'. It was a bunch of primitive shapes with rectangular prisms for trees or something. The stuff about how the AI works in terms of detection is demonstrable through the HUD, though. Also, there's scripts and demo missions around that tell you how much enemies 'know about' you, exploring the way the AI detection works.

Edited by Max Power

Share this post


Link to post
Share on other sites

I've seen pictures of the viewblock geometry for bushes and it is quite complex. Makes some user-made islands problematic.

Share this post


Link to post
Share on other sites

I have tried to find a picture where you could see what the AI see. I'm sure it was in the developer blog..

I did however find these two entries that contains some information about this:

%3C/p%3E%3Cp%3Eby%20Ond%C5%99ej%20%C5%A0pan%C4%9Bl%20(12%20December%202009)%3C/p%3E%3Cp%3E%20%3C/p%3E%3Cp%3Ereal-virtuality-going-multicore

arma2-vegetation-progress-2

Share this post


Link to post
Share on other sites

I wonder if viewGeometry for units has anything to do with the AI seeing a unit or if it just occludes the AI's ability to see things behind it.

Edited by Max Power

Share this post


Link to post
Share on other sites

Andersson thats the kind of info I'm after - very interesting ......

...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×