Not a member yet? Why not Sign up today
Create an account  

  • 7 Vote(s) - 4.86 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Advanced aerial AI (version 5.32)

#1
Introducing my version of an advanced aerial AI. This Lua script is intended as a drop-in replacement for the standard aerial AI, with many more parameters to set and far more robust altitude matching and terrain handling, and PID controls for stable flight.

This AI also includes built-in water start AI, collision avoidance AI, "dogfighting" options, vector thrust options, missile avoidance, predictive interception, VTOL takeoff, flocking, and several other features. It can also be used to control naval vessels, helicopters, and many kinds of hovercraft and airships

If you make any improvements to this AI, please share them with everyone on this thread. I'd also appreciate credit if you use this AI or a derivative of it in a tournament, or you publish a blueprint using it.

INSTRUCTIONS FOR USE: Put a Lua box down somewhere on your vehicle (it's in the "Control" tab of the build menu). Use "Q" on the Lua box. Visit the github link below. Click the "Raw" button to get the raw version of the code. Copy-and-paste (Ctrl-A,Ctrl-C) the Lua code there into the big edit box in the Lua box. Read the documentation, below. Choose appropriate AI settings for your vehicle. Click "Apply" to save the code and new settings. Watch how your vehicle behaves and continue to tweak the AI settings as desired until you get the behavior you want.

Avanced Aerial AI v5.32

If you prefer, you may also download a demo vehicle with the aerial AI already installed and working from the Steam workshop. You can copy and modify the AI from this vehicle for your own purposes, but I still recommend reading the documentation available above.
Reply

#2
Not sure if I am doing something wrong, but the plane will just fly away in a straight line for me, and when using "matchtargetaltitude", the plane cuts all engines and falls into the water.
Reply

#3
Very cool--respecting altitude settings takes a lot of the guesswork out of tuning flyers. On default settings I am getting the following error:
Code:
[string "C:/Users/isturdy/Documents/From The Depths/Lu..."]:247: bad argument #1 to 'min' (number expected, got nil)
stack traceback:
    [C]: in function 'min'
    [string "C:/Users/isturdy/Documents/From The Depths/Lu..."]:247: in function 'AdjustAltitudeForTerrain'
    [string "C:/Users/isturdy/Documents/From The Depths/Lu..."]:346: in function 'Movement'
    [string "C:/Users/isturdy/Documents/From The Depths/Lu..."]:367: in function <[string "C:/Users/isturdy/Documents/From The Depths/Lu..."]:365>
Seems to be from CurrentSpeed not being defined in the AdjustAltitudeForTerrain call.
Reply

#4
Chronos988:
So, the plane should just fly away straight if there are no enemies, though I could look into changing this behavior if desired. If it's doing that when there are enemies, that's a problem. Cutting all engines should not be happening. Is there an error in the Lua box log?

Blothorn: Very strange. I can see no reason why that error should be happening. I wonder if there are differences in the way Lua works between operating systems? I developed this on Linux. What happens if you just comment out line 247?
Reply

#5
Possibly; I am on Windows 7. No crashes since (and for reference, I am using matchtargetaltitude sucessfully). I still need to work on improving cooperation between flight plan and weapons systems, but it seems to dramatically improve the effectiveness of my Dart.

It would be nice (for VD convenience, primarily) if it tried to stay within the general area of its present location when it does not have targets.
Reply

#6
I will look into implementing that behavior. I'll have to see if there is an API call for getting the current location of the player avatar, because that behavior changes if the player is in the control seat.
Reply

#7
I have updated the OP with version 2.2 of the AI. There are numerous improvements, including:

Collision avoidance AI
Removal of "RollAngle": the AI now automatically adjusts this to maintain the desired height
"AngleBeforeTurn" is now more closely followed
An "AltitudeClamp" option has been added which helps to prevent overshooting the desired altitude
"MatchAltitudeRange" has been added, telling the AI to only match altitude within a given range of the enemy
"ClosingDistance" and "ClosingSpeed" options added to control behavior when the vehicle is far away from it's target
"ForceAttackTime" implemented

I've also had to split the documentation off due to the growing size of the AI; it no longer all fits in a Lua box.
Reply

#8
OP updated with version 2.4 of the AI. Improvements include:

Removed "TerrainAvoidanceStrategy" option 3. It's just not robust enough yet for public release.
Improved code for rolling turns, it should be more reliable now but I'll continue to test it.
Added a default option to "orbit" where the ship was spawned, as requested. I don't think it's possible to orbit the player yet, as there is no Lua code to get the player's location yet.

Update: Version 2.41 fixes a bug in the dogfighting AI
Reply

#9
I'm going to try using this when I get back for sure, do I just need to slap an LUA thing with this on in my airplanes and it's going to work or do I need to set it myself to match what the airplane did before adding this advanced aerial AI in?
I do not apply murder to the vehicle, the murder has the vehicle built around it! -ARCAGNELL0

"If there is no struggle, there is no progress" -Frederick Douglass

(2017-01-23, 04:32 PM)Shade Wrote: I think you can basically stack infinite shields in an arc
Reply

#10
Not sure what you mean by "set it myself". You put a Lua box down, paste the code in, and tweak the settings for your vehicle using the documentation. Most of the settings in the original aerial AI have a counterpart here, but there are also several new ones.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)