Author Topic: Influencing AI weapon preferences  (Read 970 times)

0 Members and 1 Guest are viewing this topic.

Influencing AI weapon preferences
I'm trying to teach the AI how to effectively use some new weapons. Both are fairly specialist weapons, but I'm not sure how to tell the AI that! My first question is how the AI chooses what weapon to use in a given tactical situation. My intuition is that it's based on relevant damage per energy consumption, weighted somehow by flags like bomber+ and possibly some estimation of chance to hit, but that's very difficult to test! If anyone knows the actual algorithm, that would be very helpful.

Anyway, some details.

One weapon is a long-range sniper cannon with limited ammunition. The AI tries to use it for everything, probably due to its high damage numbers and nonexistent energy consumption, even when it has no ammo left. I've verified this with player-use-ai in a test mission and watching the weapon selection gauge. (Manually changing weapons, which you can apparently do even while under AI control, causes it to switch back after firing a few rounds.)

The other is a high-damage high-energy-use weapon intended to be used opportunistically, to finish off a wounded target or perform a surprise "snap shot" maneuver. It's also effective against subsystems, which the AI does well enough. It has very high DPS but is also very inefficient - DPS is 250 against both shields and armor, but damage per energy consumed is only 25. I'd thought that that would cause the AI to not use it so much - I'm actually surprised it uses it against anything besides subsystems! - but I was mistaken there.

EDIT: Since writing this, I was able to get the second weapon mostly working via a hack with an artificially lowered shield factor, a copy of the original weapon with the correct damage value, and $Substitute: . This helped a lot and the AI now has enough energy to actually kill things, but it still keeps trying to use this weapon even when its energy is depleted.

There might be something very obvious I'm missing, or maybe I'm coming at this from the wrong direction. Anyone?
« Last Edit: April 03, 2015, 11:40:42 am by xenocartographer »

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Influencing AI weapon preferences
Well, first, it would be good to know if smart primary weapon selection is enabled.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

  
Re: Influencing AI weapon preferences
It is. I'm not actually sure why I enabled it, come to think of it - there isn't really any detail about what either setting does. Guess it was an impulse.