Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Naval AI with terrain & friendly avoidance, evasive maneuvers [2017-01-14]
2017-01-13, 08:51 PM
Post: #21
RE: Naval AI with terrain & friendly avoidance, evasive maneuvers [2016-12-27]
(2017-01-13 08:32 PM)ZerothAngel Wrote:  On one of my warships, I have roll props and a set of hydrofoils towards the bow. G.P. PIDs actually works well for both, one set to roll and the other set to pitch hydrofoil. PID control just seems better for most things (if you take the time to tune it) vs. the "bang-bang" approach of ACBs (and you'll often need 2-3 ACBs to do the job of 1 PID...)

As posted, your ship seemed pretty nimble. From testing, it was able to do a 90 degree heading change in 8 seconds/170 meters.

If you're interested in measuring turning speed, turning radius, and/or help in tuning the yaw PID, I have a script for that (not normally listed on my index page). It simply changes course every minute or so (due north, east, south, west) and alternates the throttle between 50% & 100%. The results are outputted to the HUD and logged to the Lua box. Since it takes full control, it has to be the only combat AI script running, of course.

I am learning to not fear the PID finally. Although I doubt it is set optimally, it wasn't as hard as I thought it was going to be tuning that roll PID to good result. So I'll have to give that a try.

That script sounds like exactly what I need, thanks! And of course thanks for your other scripts, and for all of your help!
Find all posts by this user
Quote this message in a reply
Yesterday, 12:31 AM
Post: #22
RE: Naval AI with terrain & friendly avoidance, evasive maneuvers [2017-01-14]
So I wound up adding more foils to the Cerberus, 3 each side total now, but it works beautifully with the PID. I can actually set a more aggresive pitch for speed but not have to worry about it going up in the air or being jerky. The roll & yaw are perfectly stable now too, which does seem to help detection and of course gun accuracy.

Also got my terrain avoidance sorted on both the Cerberus and the Sailfish. It's because they are so small, the Sailfish especially is only 9m high, so setting the padding to 2 and leaving everything else default seems to do it for both of them. They will still scare the crap out of me frequently, but no hull scrapes. I actually removed some foils from the Sailfish (it still probably has more than it needs).

I like the stuff you added this weekend, I turn attack runs on on almost everything, so more features & options are always good. It would be nice to actually have the AttackDistance setting like the gunship AI has if it's doable. For example on the Sailfish, I would like it to fire torps at closing angle instead of attack, but I want to keep the min/max ranges kinda tight. That way it would fire them and they might hit before it's at evade angle (where I lose sensor precision)
Find all posts by this user
Quote this message in a reply
Yesterday, 12:59 AM (This post was last modified: Yesterday 01:00 AM by Richard Dastardly.)
Post: #23
RE: Naval AI with terrain & friendly avoidance, evasive maneuvers [2017-01-14]
For PID in general where you're not trying to settle on a single value long term ( most controls & navigation fall into this ) discard the integral controller ( the I value ). Most of the time you'd do this by setting the gain to 0, but FtD for some reason isn't fond of giving you individual gains so do whatever it is you have to do. The big problem with integral controllers is windup - where it starts building a very large value because of some outside factor - and the upset this causes when the outside factor is removed.

As an example: you have PID controlled roll which works fine normally. You get holed on one side of the ship & it starts listing despite the efforts of the PID controller - the error is there every timestep so it gets added to the integral controller value, and eventually it gets enormous. You fix the hole, the ship now naturally attempts to right itself - but the integral controller has a huge error value which takes far longer to get removed than the ship takes to get upright. The end result is the PID roll control actually rolls the ship in the opposite direction while the now opposite error reduces the integral controller value. If the controller & the ship are very out of tune then the controller will just roll the ship endlessly even if you find some calm water. The two solutions are to limit the max value of the integral controller - which the built in block won't do - or just disable the integral controller entirely. Integral controllers are good for things like furnaces which want a constant value for a long time, or something like pitch which is also ( for a ship ) generally trying to stay at a fixed value, or with certain PID function forms you can use it as a damper; but generally we don't need the integral controller.

Of course you can actually use that behaviour to make a ship zigzag if you stick a PID block on the yaw output.

Poke my boat! help me improve & learn from my mistakes. WIP Wolf light destroyer. Update - 15/1/17 - decoys! Badger v94, active decoy torps
Find all posts by this user
Quote this message in a reply
Yesterday, 03:40 AM
Post: #24
RE: Naval AI with terrain & friendly avoidance, evasive maneuvers [2017-01-14]
(Yesterday 12:31 AM)Krougal Wrote:  It would be nice to actually have the AttackDistance setting like the gunship AI has if it's doable.

I'm trying to understand how this would work in the context of a ship that can only alter its heading & throttle. It works for my gunship AI because it can thrust in reverse. Would that also be fine if an AttackDistance was defined?

Because I see it happening something like this:

If distance > MaxDistance, use Closing settings
If distance < MinDistance, use Escape settings
Otherwise...
If distance < AttackDistance, use Attack settings but with reverse throttle
If distance > AttackDistance, use Attack settings but with forward throttle

I think AttackDistance defined this way would work for both broadsiding mode and attack run mode. (It would probably make more sense in attack run mode though.) In attack run mode, if it couldn't maintain its AttackDistance (i.e. target was faster), it would switch to Escape settings until it could get away to MaxDistance.

My Workshop | My FtD Lua Scripts
Find all posts by this user
Quote this message in a reply
Yesterday, 04:13 AM (This post was last modified: Yesterday 04:15 AM by Krougal.)
Post: #25
RE: Naval AI with terrain & friendly avoidance, evasive maneuvers [2017-01-14]
(Yesterday 03:40 AM)ZerothAngel Wrote:  
(Yesterday 12:31 AM)Krougal Wrote:  It would be nice to actually have the AttackDistance setting like the gunship AI has if it's doable.

I'm trying to understand how this would work in the context of a ship that can only alter its heading & throttle. It works for my gunship AI because it can thrust in reverse. Would that also be fine if an AttackDistance was defined?

Because I see it happening something like this:

If distance > MaxDistance, use Closing settings
If distance < MinDistance, use Escape settings
Otherwise...
If distance < AttackDistance, use Attack settings but with reverse throttle
If distance > AttackDistance, use Attack settings but with forward throttle

I think AttackDistance defined this way would work for both broadsiding mode and attack run mode. (It would probably make more sense in attack run mode though.) In attack run mode, if it couldn't maintain its AttackDistance (i.e. target was faster), it would switch to Escape settings until it could get away to MaxDistance.

I thought scenario 1 was already how your naval AI works, with implied "Else, use Attack Settings"

So more like how the Naval AI card, you can specify the begin broadside range, which can be max -10 or even lower. Being as broadside and attack are the same in your script (I think?) basicly that same setting.

So for example I want to switch to attack profile at 1800, above that I want it to close up to 2000, and I want it to go to 1600 minimum....ok...something broken there or I am a complete idiot.....

Oh. Ok. It only makes sense in the context of attack runs, to clamp max distance but yet insure it spends some time at closing angle. So like I want it to drive in and out between 1600 and 2k, but I want to make sure it is in closing angle for 200m before switching to attack angle for 200m and then finally evade...am I overcomplicating it? Those ranges might not even be big enough, and of course since it is hard to eyeball with any kind of precision what angle you're facing the enemy at range I suppose I'm not really sure what exactly is happening when.
Find all posts by this user
Quote this message in a reply
Yesterday, 04:50 AM
Post: #26
RE: Naval AI with terrain & friendly avoidance, evasive maneuvers [2017-01-14]
Let me clarify how things work as of the latest update. I'll probably add this to the OP eventually too.

Broadsiding mode (AttackRuns = false, the default)
If distance > MaxDistance, use Closing settings
If distance < MinDistance, use Escape settings
Otherwise use Attack settings

Attack run mode (AttackRuns = true)
Firstly, this mode keeps track of whether it is attacking or not, unlike broadsiding mode where the settings used are solely based on distance.

If distance > MaxDistance, use Closing settings. Also set Attacking = true.
Otherwise if Attacking = true, then use Attack settings
Otherwise use Escape settings (i.e. Attacking = false)

If at any time, distance < MinDistance, set Attacking = false.

So against a stationary target:
  1. Your ship will close in to MaxDistance (using Closing settings),
  2. Switch to Attack settings
  3. Stay on Attack settings until hitting MinDistance
  4. Switch to Escape settings
  5. Stay in Escape settings until hitting MaxDistance
  6. Then it will (very briefly) switch to Closing settings and then repeat the whole process again

My Workshop | My FtD Lua Scripts
Find all posts by this user
Quote this message in a reply
Yesterday, 07:34 AM
Post: #27
RE: Naval AI with terrain & friendly avoidance, evasive maneuvers [2017-01-14]
Yeah, I guess it already does more or less what I'm trying to do anyway.
I guess I could set the attack angle fairly low to get the effect I'm looking for.
That would make it do "Crazy Ivans" constantly, which would probably be good since the LAMS don't cover the front.
I went to bigger faster torps, and the range seems to be about 1.9k at best (with 1 fuel tank) so been trying to squeeze that last bit out of them.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)