Enemy AI

Talk among developers, and propose and discuss general development planning/tackling/etc... feature in this forum.
Post Reply
Psyco Diver 69
Bounty Hunter
Bounty Hunter
Posts: 130
Joined: Wed Aug 01, 2007 1:32 am
Location: Here
Contact:

Enemy AI

Post 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
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Enemy AI

Post by klauss »

Supposedly, the AI script has provisions for that.

So I guess it's just not working right.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
breese
Bounty Hunter
Bounty Hunter
Posts: 152
Joined: Thu Sep 02, 2010 8:00 pm

Re: Enemy AI

Post 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.
breese
Bounty Hunter
Bounty Hunter
Posts: 152
Joined: Thu Sep 02, 2010 8:00 pm

Re: Enemy AI

Post 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.
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Enemy AI

Post 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.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
athomic1
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Wed Apr 08, 2009 6:07 am

Re: Enemy AI

Post 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.
breese
Bounty Hunter
Bounty Hunter
Posts: 152
Joined: Thu Sep 02, 2010 8:00 pm

Re: Enemy AI

Post 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.
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Enemy AI

Post 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.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Re: Enemy AI

Post 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.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
breese
Bounty Hunter
Bounty Hunter
Posts: 152
Joined: Thu Sep 02, 2010 8:00 pm

Re: Enemy AI

Post 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.
TBeholder
Elite Venturer
Elite Venturer
Posts: 753
Joined: Sat Apr 15, 2006 2:40 am
Location: chthonic safety

Re: Enemy AI

Post 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.
"Two Eyes Good, Eleven Eyes Better." -Michele Carter
pheonixstorm
Elite
Elite
Posts: 1567
Joined: Tue Jan 26, 2010 2:03 am

Re: Enemy AI

Post 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.
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
AVBJim
Merchant
Merchant
Posts: 42
Joined: Tue Dec 22, 2009 9:16 pm

Re: Enemy AI

Post 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.
pheonixstorm
Elite
Elite
Posts: 1567
Joined: Tue Jan 26, 2010 2:03 am

Re: Enemy AI

Post by pheonixstorm »

klauss added the patch so make sure to grab it off svn
Because of YOU Arbiter, MY kids? can't get enough gas. OR NIPPLE! How does that mkae you feeeel? ~ Halo
Post Reply