(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!

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)

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.

(2017-01-16 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.

(2017-01-16 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.

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.

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.

@OP is it possible to set up a lua controller to switch shield mode from reflect to laser absorb? in adventure i dont really have that ability on other ships only the one im on and ofcourse i cant warp to the ship or get 3rd person view so they are truely independant.