Page 1 of 1

Enemy AI

Posted: Wed Mar 02, 2011 9:25 pm
by Psyco Diver 69
Wouldn't it make more sense that if you damage someone enough they'll just run away? I just restarted a game and I already pulled a bunch of kills in the Llama. I understand in missions you need to kill the enemy, but in like random encounters to me it would make sense they would get their nose blooded some and run, unless you kill them quickly or chase them down

Re: Enemy AI

Posted: Wed Mar 02, 2011 9:56 pm
by klauss
Supposedly, the AI script has provisions for that.

So I guess it's just not working right.

Re: Enemy AI

Posted: Thu Mar 03, 2011 6:40 pm
by breese
klauss wrote:Supposedly, the AI script has provisions for that.

So I guess it's just not working right.
While developing the autodocker, I did an experiment where I invoked other AI scripts instead of the autodocker. For instance, the BarrelRoll script worked beautifully. However, I noticed that some of the scripts did not do much, e.g. the evasion scripts did not evade. I did not know if I had used them incorrectly or if they were erroneous, and I did not have time to follow up on it. It might be a good idea if we quality check the various scripts.

Re: Enemy AI

Posted: Sat Mar 05, 2011 3:35 pm
by breese
breese wrote:It might be a good idea if we quality check the various scripts.
I just went through all the AI scripts in src/cmd/src/ai/hard_coded_scripts.h.

I found that the following scripts behave different than I would expect:
* AgressiveLoopAround: Moves towards the target and crashes into it.
* Kickstop: Does not stop.
* MatchVelocity: Does not move.
* RollFacePerpendicular: Does not roll.
* Takeoff/TakeoffEveryZig: Just moves straight ahead.
* VeerAway/VeerAwayITTS/VeerAndVectorAway/AfterburnVeerAndVectorAway: Moves towards the target and crashes into it. The AfterburnVeerAndTurnAway script seems to work though.

Re: Enemy AI

Posted: Sat Mar 05, 2011 8:04 pm
by klauss
That's odd, many of those scripts are central to current AI - are you sure you just didn't know how to use them?

Because I would think, if they didn't work, most NPCs wouldn't either. MatchVelocity for instance is referenced in many xml ais.

Re: Enemy AI

Posted: Sun Mar 06, 2011 10:22 am
by athomic1
klauss wrote:MatchVelocity for instance is referenced in many xml ais.
But does the ship actually try to match velocities? That could be hard to tell.

Re: Enemy AI

Posted: Sun Mar 06, 2011 12:28 pm
by breese
klauss wrote:That's odd, many of those scripts are central to current AI - are you sure you just didn't know how to use them?

Because I would think, if they didn't work, most NPCs wouldn't either. MatchVelocity for instance is referenced in many xml ais.
On further investigation, it appears that MatchVelocity does work -- it just worked differently from what I had expected. The velocity it matches is the velocity of the target at the moment when the script is invoked. If the target changes velocity, the script will still try to match the initial velocity.

I am positive that the veering scripts are erroneous. It appears that they are given a relative heading that they treat as an absolute heading.

As for the other scripts, who knows? I have simply described the observed behavior, and I find it hard to reconcile that with the names of the scripts. But the scripts could have bad names. Difficult to tell with the current level of code comments.

EDIT: I also noticed that most scripts, including those that work correctly, jitters/shakes when they face a target straight on.

Re: Enemy AI

Posted: Sun Mar 06, 2011 5:50 pm
by klauss
breese wrote:On further investigation, it appears that MatchVelocity does work -- it just worked differently from what I had expected. The velocity it matches is the velocity of the target at the moment when the script is invoked. If the target changes velocity, the script will still try to match the initial velocity.
Do we want to document that behavior, or fix it?
breese wrote:I am positive that the veering scripts are erroneous. It appears that they are given a relative heading that they treat as an absolute heading.
This is a nice oportunity for code review - if we made a patch, we could have it reviewed by the AI's author ;) (and any others that may be interested)
breese wrote:EDIT: I also noticed that most scripts, including those that work correctly, jitters/shakes when they face a target straight on.
This is a problem of the scheduling method, when units have low priority on the physics/AI scheduled, their movements are imprecise and it results in jitter.

I don't know if it's that bad - people do jitter ;) - as long as it's moderate.

Re: Enemy AI

Posted: Tue Mar 08, 2011 1:04 am
by klauss
Speaking of AI, I'm getting a lot of this on the console:
cannot find AI script FacePerpendicularFast
That might indicate some AI issues.

Re: Enemy AI

Posted: Wed Mar 09, 2011 7:12 pm
by breese
klauss wrote:Do we want to document that behavior, or fix it?
Not sure. We should probably document it, and write a new script that continuously adjust the velocity.
klauss wrote:I don't know if it's that bad - people do jitter ;) - as long as it's moderate.
Well, these scripts have Parkinsons.

Regarding FacePerpendicularFast, this is an error in data/ai/events/bomber.agg.xml. It has a rule that refers to the script as "FacePerpendicularFast", but that is its C++ name, not its scripting name, which is "face perpendicular fast" (the name mapping can be found in src/cmd/ai/script.cpp). However, there is a comment above the rule that says that it is experimental. Maybe we should just delete the rule.

Re: Enemy AI

Posted: Wed Jun 15, 2011 4:10 am
by TBeholder
Looked there again. Those turned out to be built-ins, and the problem was... That's... awkward... :oops:
Added trivial patch in the bug-tracker.

Re: Enemy AI

Posted: Wed Sep 21, 2011 5:22 am
by pheonixstorm
patch should go up this week as well as a few other data related changes. Once its up let me know if it fixes the problem for everyone so I can close out the tracker report.

Re: Enemy AI

Posted: Wed Sep 21, 2011 4:52 pm
by AVBJim
Whether or not an enemy that has been damaged should run would probably be determined by whom the enemy is. For example, the cultural bias for the Aera would be to fight to the bitter end. Military type ships doing missions to guard something would probably fight to the bitter end or until whatever they are protecting is out of danger. The ULN seem to go in for suicide attacks with smaller, possibly unarmed, units, since their objective is to crash into you, then they probably will not go for running much. Military type craft that have a mission to complete should normally not withdraw until the mission assigned is complete. However, Merchant Guild and other merchant vessels would most likely run at the first indication something is hostile to them. Zealots of a particular group, I think would tend to fight through also.

So when and whether or not a ship should run when x amount of damage is done is really a function of their mission requirements and mindset, not the amount of damage they have taken. Of course, there are limits to the complexity and variety of scripts and writing one for every race/situation is almost impossible.

Re: Enemy AI

Posted: Wed Sep 21, 2011 9:29 pm
by pheonixstorm
klauss added the patch so make sure to grab it off svn