Author Topic: The Myths of AI accuracy revealed  (Read 3201 times)

0 Members and 1 Guest are viewing this topic.

Offline Fabian

  • AI Code Modulator
    Temporal Mechanic
  • 25
The Myths of AI accuracy revealed
As it comes up again and again that ai_accuracy only influences the rate of firing, but not the vector I've now made some real tests and experiments.

Here are the results:

The ai_accuracy does influence the aiming vector. Not only is the code there, but it also works.
 
I doubt anyone was able to play freespace properly if the AI would hit every time ... (even though on insane it almost hits every time if flying in a straight line.)
 
Of course the ai_accuracy is best felt on low levels like easy or very easy:
 
There are 4 exceptions for using the estimated enemy position and using the real enemy position instead:
 
- subsystems: AIM is always directly hitting at target
- enemy is not in field of view (so it won't even try to fire)
- The target was just acquired. For 1 sec its using the real enemy position.
- The fighter is trying to gain a lock on target, but then it also won't fire primaries.
 
So the AI has only an unfair advantage in case of subsystems and that 1 sec after target acquired, but I'm not even sure it uses those to shoot.
 
The Aiming is thrown really off when the object first appears in field of view and gets more precise the longer the object is in the field of view. (scale up to 17 or even 20 on lower levels)
 
I've tested with FS2 campaign without mods.
 
The accuracy in FS2 varies much depending on skill level, final scales by which the real vector is put off, ranging from:
 
2.0 very easy to 1.2.
 
To sum it all up:
 
- Accuracy is always perfect if AI aims for a subsystem.
- Accuracy really works as expected (unless for subsystems)

Accuracy does also influence the rate of firing a bit, because if the aim is off too much, it won't even try to fire.

Try setting the ai_accuracy in the corresponding table to feel the difference.

For example set it to 1.0f ... ;-) and wonder how good the AI is at aiming suddenly ...

Questions?
 
cu
 
Fabian
 
PS: If you don't believe me: Make a 1 on 2 mission in FS2, let your friendly AI play dead (ai-play-dead) and let the enemy attack first it, then you ... (make a ship-guardian sexp on yourself) ...
 
Then see how the enemy fails to first AIM properly at your still standing wingmate and how it shots get more accurate over time ...
 
Then put yourself in 3rd person view and fly in a straight line possibly on something like "very easy" (change _before_ loading the mission), then watch how the enemy misses quite a few shots on you.
 
Go head on and fly in a straight line again. Possibly view from enemy, the accuracy will be off again and gets more accurate in time.

PPS:

Here is a log output of the above scenario:

Code: [Select]
(first we are out of field of view as dot is below 0.25, so we can see the exact position)
Predicted enemy pos = exact enemy pos, real_dot_to_enemy = 0.23, aip->target_time = 90.42, aip->ai_flags & AIF_SEEK_LOCK) = 0
Predicted enemy pos = exact enemy pos, real_dot_to_enemy = 0.24, aip->target_time = 90.45, aip->ai_flags & AIF_SEEK_LOCK) = 0
Predicted enemy pos = exact enemy pos, real_dot_to_enemy = 0.25, aip->target_time = 90.47, aip->ai_flags & AIF_SEEK_LOCK) = 0
(Now we can almost see him, so we predict the position and throw the aim off ...)
Predicted enemy pos != exact enemy pos, real_dot_to_enemy = 0.26, aip->target_time = 90.50, aip->ai_flags & AIF_SEEK_LOCK) = 0
Throwing aim off by scale: 8.721652
Predicted enemy pos != exact enemy pos, real_dot_to_enemy = 0.27, aip->target_time = 90.54, aip->ai_flags & AIF_SEEK_LOCK) = 0
Throwing aim off by scale: 8.767686
(... enemy shoots at my wing man and scale slowly gets less and less)
Predicted enemy pos != exact enemy pos, real_dot_to_enemy = 1.00, aip->target_time = 100.21, aip->ai_flags & AIF_SEEK_LOCK) = 0
Throwing aim off by scale: 2.781154
Predicted enemy pos != exact enemy pos, real_dot_to_enemy = 1.00, aip->target_time = 100.27, aip->ai_flags & AIF_SEEK_LOCK) = 0
Throwing aim off by scale: 2.749156
Predicted enemy pos != exact enemy pos, real_dot_to_enemy = 1.00, aip->target_time = 100.28, aip->ai_flags & AIF_SEEK_LOCK) = 0
Throwing aim off by scale: 2.692149
(... well and here he destroyed the play-dead wing man ...)

You can also see this by looking from the enemy AI. He will AIM wrong first and you can clearly see this.

predict_position_delay from ai_profiles.tbl does determine how often he will try to adjust his aim and predicted enemy position.

Currently this seems to be set pretty high in FS2, so it seems that the AI is always on the same spot, but this is also due to this value.

It also is, because I think updating all the AI for each frame would have needed too much computing power back in 1998, so its only done sporadically, which also gives the impression that the AI is not using accuracy ... but it really is using it, it just aims for a longer time on the wrong spot ...

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: The Myths of AI accuracy revealed
I always knew UT's ridiculously low accuracy values would bite us on the arse sooner or later. :p
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: The Myths of AI accuracy revealed
so why do the other bombers in bearbaiting fail to bother helping you during the attack on the beam cannons. figure 4 bombers, 4 beam cannons and you think they could figure it out. considering theyre using the exact position and all. :D
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: The Myths of AI accuracy revealed
Hmm.. Might work with fighters then, though dunno how much that helps with turrets.. At least capship turrets always seem to prioritize enemy subsystems (weapons subsys and turrets) before 'just firing at the hull' which then seems to bypass the whole ai accuracy quite neatly.. Though i could be wrong again  ;)
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Fabian

  • AI Code Modulator
    Temporal Mechanic
  • 25
Re: The Myths of AI accuracy revealed
so why do the other bombers in bearbaiting fail to bother helping you during the attack on the beam cannons. figure 4 bombers, 4 beam cannons and you think they could figure it out. considering theyre using the exact position and all. :D

I have not tested this, so I can only speculate:

- It might be that there is a special "bomber AI", which does not use the ai_chase subfunction.
- Or they had no real orders to destroy the forward beam cannons.

It is really quite strange though, because once they have a lock, they should just use their cyclops on the beam cannons ...

I'll have to investigate that ...

In Warzone, restored (last mission) your wingmen (fighters though) do help and manage to destroy one beam cannon ...

Hmm.. Might work with fighters then, though dunno how much that helps with turrets.. At least capship turrets always seem to prioritize enemy subsystems (weapons subsys and turrets) before 'just firing at the hull' which then seems to bypass the whole ai accuracy quite neatly.. Though i could be wrong again  ;)

Yes it seems you are :P.

The bypassing of accuracy for subsystems is afai see only done for fighters (and bombers?) and normal no-turret primaries. Turrets have its own code:

set_predicted_enemy_pos_turret, where in general the same formula is used, but turrets AIM is not affected by EMP or nebula. And the code that uses this function has no bypassing of using an exact position ever.

So nope turrets do not bypass the ai accuracy.

And again this should be quite clear from just playing on an easier level and seeing an AAA beam going near you, but not destroying you :-).

It really is only for small ships, where the guns point to where the ship points ... I guess before [V] added it, the AI was not able to destroy subsystems on lower levels. See how much problems they sometimes have already and then add some aiming error to it ... Well ...

cu

Fabian

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: The Myths of AI accuracy revealed
Well... That reference to AAA beam is kinda off as beams have always used their own special accuracy (or rather.. inaccuracy) modifiers.. Probably just in addition to 'normal' ai accuracy
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Fabian

  • AI Code Modulator
    Temporal Mechanic
  • 25
Re: The Myths of AI accuracy revealed
Well... That reference to AAA beam is kinda off as beams have always used their own special accuracy (or rather.. inaccuracy) modifiers.. Probably just in addition to 'normal' ai accuracy

Well you got  me ... :P

The same is true (using ai accuracy) for all other turrets though ...

cu

Fabian