NEW VERSIONS - SIMPLE VERSION AND EXPERIMENTAL VERSION
After much delay here are two versions for people to try. Rename to Aiship.c and paste into Program/Sea_Ai as usual.
Both versions result in much improved headway that the AI can make against the wind and both in my opinion may result in more risk of collisions, but differ very significantly otherwise.
The simple version uses the same method i have already released almost to the letter and applies equally to all ships (no matter their sail skill or any other attribute), with two changes:
1) The rotation force exerted upon ships has been reduced from 0.0015 to 0.0010 in response to miklkit's observations.
2) When sailing close to the wind the script forces the AI to raise its sails to 100%, because the AI normally tends to reduce sail to 50% once it is forced significantly off course. The AI is still able to reduce sail when it meets obstacles but not as well as might otherwise and this change produces the gains in effectiveness and the increased risk of collisions of this version.
Nonetheless, my own personal opinion is that this simple version is the best mix between simplicity, effectiveness and increased risk of collisions and should have very little impact on framerates. I would recommend it to those who just want ships that tack reliably upwind.
The experimental version uses three seperate methods modified for ten seperate levels of effectiveness - one for each point of Sailing skill from 1-10. This includes variations of the method above and two additional methods that force the AI to sail on one side of the wind for longer. Each skill level in Sailing has its own tacking formula and ships increase greatly in tacking proficiency from 0-5 (5 being equivalent to the simple version above) and somewhat from 6-10.
There are some benefits to the higher levels in tacking, and the way the ships stay on one side of the wind may seem more correct, but the ships generally do not improve all that much on the simple method above. The code is, however, FAR longer and more complex, and could have a number of drawbacks, although I hope these have been solved;
1) Regular pauses every second or so for a fraction of a second or other performance effects - I had this issue before, but believe I have improved it by rewriting some of the code. Nonetheless, this code is at least 15 times longer than the simple version - it has far more potential for an impact on framerates than the simple version.
2) High rotation forces (when crossing the wind these range from 0.006-0.0016 similar to the simple version, but go as high as 0.0055 when trying to keep AI from entering the wind) needed to keep the AI out of the wind can introduce immersion jarring, but temporary 'spins' on AI ships when the wind changes.
3) With sailing skills 6-10, the improved methods come with higher risks of the AI doing something dumb like crashing into things or not taking logical paths.
4) Sail skills 1-3 are very poor tackers (but improve very rapidly between 1 and 3), but that is intended
5) Other bugs i am not aware of.
This version represents all of my latest progress but frankly, i feel it may simply have been wasted given how well the simple version works (and how much simpler it is) just by forcing sails up. It produces some gains, but in my opinion not enough to warrant the hugely more complex code. It is put here for the benefit of the adventurous and for others to judge which version is best.
Ultimately I think the original, simple method just plain works most reliably and yet gives something like 80% of the tacking performance. Im interested to hear what you all think. I should note though that I could use any method from the experimental version and apply it universally, which would make the code much shorter and simpler (maybe 3-4x longer than the simple version for the most advanced method) if people feel that any particular method works best.
Cheers!