View Full Version : Volunteers needed, to test experimental AI tweaks
Hi guys! In short, I'm looking for volunteer(s) who are currently playing SH5 campaign (with or without TWoS, the only thing required would be that you have JGSME mod manager set up), who would be willing to test changes I've made to TDW's version of Airplane.aix script in order to make planes in game more dangerous.
If you're interested, here's a little more detailed explanation:
Plane AI in SH5 is governed by Airplane.aix file located in data/Scripts/AI folder. Vanilla version was (like most of the game) very buggy and modders have been trying to improve it, most notably TheDarkWraith in his IRAI mod (this is the version used by TWoS megamod among others). Unfortunately TDW never finished working on it, and plane AI still has many problems leading to aircraft not attacking a U-Boat when they should or crashing into ocean. This was discussed at length and tested in a thread I've started some time ago (https://www.subsim.com/radioroom/showthread.php?t=248833), and based on findings from this thread I did some changes to TDW's version of Airplane.aix aiming to make planes more of a threat to the player.
Unfortunately, my free time is very limited these days and I cannot do any sort of extensive testing, especially testing in campaign (all my own tests were done in specially prepared single missions to have a controlled environment where I can make various script changes and compare results. Campaign doen't work that way - planes fly in various groups, weather conditions, approach from different directions, plus there are various tactics emploed by player to evade the attack - all this has an impact on how well AI will work). This is why I'm looking for someone who is currently playing a campaign to test changes and provide feedback.
How would this work? Here, you'll find a mod that replaces Airplane.aix with new script:
https://www.subsim.com/radioroom/downloads.php?do=file&id=6291
Copy it to your mods folder (or TWOS_Parts folder if you use TWoS). It can be enabled or disabled through JGSME at any time during your campaign, even mid-patrol, and will work both for vanilla game and for TWoS. After enabling it, when you are attacked by an aircraft, please post here the results:
- What type of plane (if you had time to check or use external cam)
- How did you respond to the attack (dive, fight it with AA, etc)
- What was the result (did the plane drop any bombs? Did it crash into ocean or did it do some other weird maneuver?)
I hope to pinpoint planes and situation that lead to least satisfying results, and use this to improve their behaviour by further tweaking either the script or plane parameters.
Final note on credits: as noted above, I was working on version of the script created by TheDarkWraith and included in TWoS megamod, so most of the script is TDW's work, I just changed parts that led to buggy behaviour (specific info on changes made is in comments within script file).
Muckenberg
01-31-23, 05:33 PM
Hello, I will keep you updated. I just started Happy Times.:Kaleun_Salute:
Hello, I will keep you updated. I just started Happy Times.:Kaleun_Salute:
Thanks :salute:
propbeanie
01-31-23, 07:47 PM
I am quite busy right now kapuhy, but if I can finish up a few things and get back to having fun actually playing the game, I'll do some reports. But it will be at least several weeks before I can. :salute:
Maybe I will have time on this weekend. But without guarantee.
Thanks guys :up:
Anyways, from my own testing in single missions so far, this current version seems to improve the following:
- planes more willing to drop bombs (still a lot of "dry runs" but there should be a bomb dropped on player within 1-5 minutes of plane getting in range though efficiency varies from plane to plane)
- way faster turning back for another attack, which also means they keep you in range of their machine guns for better suppression
- planes attempt to drop bomb on place where U-Boat has just dived, and while they almost always miss it's still better than immediately breaking off the moment your periscope hides under water
Downsides:
- weird maneuvers that sometimes lead to stalling (especially with level bombers)
- accuracy in bomb drops is poor.
propbeanie
02-01-23, 11:04 AM
My guess is that there is still too much SH3/4 AI still in SH5 for the scripting to influence too much of their behavior. It will be interesting to test. Do you have the planes set to Elite (CrewRating=4)? That is almost a necessity in ASW planes, and improves their "maneuvering". Those dry runs, of not dropping occur in SH4 irritatingly all of the time, especially when the player sub dives prior to visual contact. Strange thing is, on the 2nd pass from the plane, they will drop their bombs almost precisely where the submarine dove, almost like they dropped a dye marker on their first pass - which would be cool to model in - but that "accuracy" there is uncanny and unrealistic. Surely, the radar equipped plane was able to gather course and speed data inbound, and could more accurately anticipate where the sub would be? If the airplane makes visual contact, it almost always drops bombs on the first pass, and strafes the water and/or (surely) diving boat. The plane's turning tighter and maintaining contact with the sub in SH5 is something that would be nice to have in SH4, where they often fly 12-15 nm beyond before coming back for a 2nd and 3rd pass... Cool stuff, kapuhy! :salute:
Do you have the planes set to Elite (CrewRating=4)? That is almost a necessity in ASW planes, and improves their "maneuvering".
Hmm, I've done my testing on Veteran which is default rating. Now, I just repeated test on Elite with weird results - default unchanged AI did drop bombs with Catalina, though it missed by a lot, while changed AI achieved a direct hit but took more time to drop a bomb. Will have to make further tests on Elite rating I guess.
Edit: Wait I take that back. I mistakenly set "Poor" crew rating instead of Elite. Which makes it weirder still: "Poor" default AI (by default I mean unchanged IRAI script in this case) does drop bombs on moving target, and in first pass to boot! It doesn't hit, sure. But actual "Elite" AI, just like "Veteran", does not drop a bomb at all making endless dry runs...:06:
If the airplane makes visual contact, it almost always drops bombs on the first pass, and strafes the water and/or (surely) diving boat.
Not the case in SH5. Dropping bombs on first pass is a rarity except for level bombers (who do drop bombs but miss by an entire zipcode).
Edit: case in point - look at the video embedded in this post: https://www.subsim.com/radioroom/showpost.php?p=2736108&postcount=1
propbeanie
02-02-23, 07:07 AM
Most interesting... SH4 does similar, but will almost always drop on the first pass when the boat stays on the surface, and usually on the 2nd if it doesn't on the first. In real life, the dive bombers used their machine gun tracers to help them "aim" their airplanes for the bomb drops, so if you're seeing bullet splashes across the boat, you would assume they would drop right on you... they must have crippled the AI for the scripting, or maybe WITH the script... I'll have to look at that for my curiosity... lol
they must have crippled the AI for the scripting, or maybe WITH the script... I'll have to look at that for my curiosity... lol
Script is simple. There are two boolean functions (syntax looks like Javascript, kind of):
Plane:HasBombs()
Plane:CanFireBombs()
These are conditions for action Plane:FireBombs();
So if both are true, plane should execute action.
Except - I have checked approaches with AI Debugger (very useful SH5 tool allowing you to check values of all functions of all scripts in any given moment of time), that there is a moment during approach when both conditions are true and the plane still doesn't execute the action.
There must be something within Plane:FireBombs() function that prevents it from doing what it is supposed to be doing, but what? I don't have access to that code itselt, just the script that uses it. So, my solution was simply to maximize time plane spends over target (by switching from normal bomb approach to "circle target and strafe it repeatedly" behaviour), increasing probability that Plane:FireBombs() will be triggered at some point.
Muckenberg
02-02-23, 12:20 PM
Hello, I would like to ask you if you would provide me with your missions that you created for testing. I could test different situations of the pomorka's behavior, flak fire, evasive maneuvers, submerged, etc. I would give you the test results for comparison here on Subsim.
I really don't know when I will come across a plane in the campaign, but I will try to sail as close to England as possible.
Hello, I would like to ask you if you would provide me with your missions that you created for testing. I could test different situations of the pomorka's behavior, flak fire, evasive maneuvers, submerged, etc. I would give you the test results for comparison here on Subsim.
Sure, but it's just a simple template (with one U-Boat, one plane and neutral ship I put for reference so that I know how far I want to put plane from the boat). I am changing it in editor for every test (switching/adding planes, changing weather, direction of attack, starting depth and speed of U-Boat and so on).
Do you know how to use Mission Editor in SH5? If so, here's a mission template - install it like other mods and tweak to your liking.
https://drive.google.com/file/d/1KzoN4UhUw_CXL4JfYYvaiJOEld2Z7vQT/view?usp=sharing
If you don't know how to edit missions, I'll write instructions for you.
Muckenberg
02-02-23, 01:36 PM
Unfortunately, I don't know how to work with the mission editor. if you made a guide, you would be very kind. Thank you very much. :Kaleun_Salute:
Unfortunately, I don't know how to work with the mission editor. if you made a guide, you would be very kind. Thank you very much. :Kaleun_Salute:
Ok, I should have time on Sunday to make a guide and post it.
I've just started a new campaign - it's necessary to dive back into the game from time to time...
So, June 20, 1940 midway through the North Sea - 2 planes are circling, watching, then one of them dives, drops 2 bombs!
Everyone is wounded and 55% of the hull is left
Conclusion : obviously, this is a change from previous experiences where planes were diving in the water, or passing by as tourists ...
Lesson well learned, if plane in sight, I dive !
Unfortunately, I don't know how to work with the mission editor. if you made a guide, you would be very kind. Thank you very much. :Kaleun_Salute:
Here's the video, hopefully my mumbling is understandable but if anything is unclear feel free to ask:
https://youtu.be/Tu5_kHyMRU4
Lesson well learned, if plane in sight, I dive !
https://i.imgflip.com/sqtko.jpg
Thanks for sharing :up:
Sorry kapuhy but hadn't had the time on the weekend to check and test your AI script and report my experiences and observations.
Sorry kapuhy but hadn't had the time on the weekend to check and test your AI script and report my experiences and observations.
No problem GrenSo, it can wait for better time :salute:
Muckenberg
02-06-23, 07:48 AM
Good day
Thank you very much for the guide to the mission editor.
My observations for now. I was attacked by two Spitfires and I deliberately did not dive and shoot the Flak. The planes only shot at me with machine guns and did not drop bombs. And I let them fly repeatedly. Unfortunately, an escort ship was approaching, so I managed to shoot them down and had to sink.
I was spotted by an Anson patrol plane and again I didn't sink at the start of the attack.and ordered full throttle and zigzagging. If I zigzagged the plane still attacked only through the machine gun. When I finally sank the plane started to fly away. Anson spotted me again and attacked again. now I wasn't meandering anymore and the plane dropped the bombs and I have to say, not bad. I'm undamaged, but the bombs didn't land badly at all. Then the plane took off.
I'll still be hanging around England and reporting back. :) :Kaleun_Salute::Kaleun_Salute:
Good day
Thank you very much for the guide to the mission editor.
My observations for now. I was attacked by two Spitfires and I deliberately did not dive and shoot the Flak. The planes only shot at me with machine guns and did not drop bombs. And I let them fly repeatedly. Unfortunately, an escort ship was approaching, so I managed to shoot them down and had to sink.
I was spotted by an Anson patrol plane and again I didn't sink at the start of the attack.and ordered full throttle and zigzagging. If I zigzagged the plane still attacked only through the machine gun. When I finally sank the plane started to fly away. Anson spotted me again and attacked again. now I wasn't meandering anymore and the plane dropped the bombs and I have to say, not bad. I'm undamaged, but the bombs didn't land badly at all. Then the plane took off.
I'll still be hanging around England and reporting back. :) :Kaleun_Salute::Kaleun_Salute:
Thanks :up: I didn't make a test with Spitfire yet, will add this to my list. Plane characteristics (speed, stall speed, turn radius etc.) might play a part in why planes do or don't drop bombs. This, and zigzagging - from what you write it might also cause planes to get stuck in a dry run loop.
Muckenberg
02-19-23, 07:09 AM
Hello. Today I was attacked by two Hurricanes, I was still sailing straight but I put full speed. one aircraft behaved by circling the submarine, machine-gunning the submarine and dropping a bomb on the third pass. Fortunately, not exactly. It continued to circle the submarine and then fell into the sea.
The second plane after the first joint pass continued as we were used to with TWoS and turned it around only at a distance of several kilometers (maybe) :D It did not drop the bomb and only attacked with weapons.
I loaded the saved position with Anson once more and now I wasn't zigzagging, just full speed. The plane circled me twice and then dropped the bomb. And exactly. He sunk me. :k_confused:
It's strange to see some planes crashing into the sea by themselves - well, it's obviously quite unrealistic and it should be possible to simply remove this action from the script (beginner pilot removed)
Hi Muckenberg, thanks for the report. Hopefully I'll get some free time during next weekend to try to experiment with plane characteristics and see how they come into play. For now thing to look into: spitfires, zigzagging, and crashing into sea.
As for second Hurricane continuing, that's a but weird - it should only behave this way if it's out of bombs...
It's strange to see some planes crashing into the sea by themselves - well, it's obviously quite unrealistic and it should be possible to simply remove this action from the script (beginner pilot removed)
If only it was so simple... avoiding crashing into water is done by following block of code:
strategy AvoidImpact(Plane)
{
precond
{
Plane:StrafingTooClose()
}
action
{
Plane:AvoidWaterImpact();
}
}
Simple, right? Problem is, we don't know how exactly StrafingTooClose() and AvoidWaterImpact() work. Their code is inside sim.act file which we can't read. So we can only experiment with adding some extra conditions for these functions - but not modify functions themselves.
Edit: only way I was able to eliminate crashing into water completely, was by switching ALL planes to "level bomber" mode and adjusting their minimum height so that they just pass high over target trying to carpet bomb it. With this approach, however, they were so inaccurate they might as well be removed from game to save some fps.
March 41 - 2 spitfires hover over the sub gracefully; these planes do not appear to be armed and are easily shot down
March 41 - 2 spitfires hover over the sub gracefully; these planes do not appear to be armed and are easily shot down
Thanks!
According to game files they are armed - but these light fighter types are also the worst in terms of being able to use their weapons. In my tests Spitfires crashed into sea more often than drop bombs, unfortunately.
There's also another problem with these planes - they should be extremely rare in game (please correct me it I'm wrong, but for all I know there was not a single historical case of Spitfire or Hurricane attack on U-Boat at sea), yet from what I hear SH5 players encounter them more often than dedicated anti-submarine patrol planes.
I'm not a campaign expert, so maybe there's a reason this wasn't done but as far as I'm concerned, game would benefit from drastic reduction of light fighter planes range, to the point where player would only encounter them close to harbors.
propbeanie
04-24-23, 02:46 PM
Depending upon how much of SH4 is in SH5 kapuhy, look at the AirBase cfg files for the AirGroups. In SH4, there are Small, Normal and Large Type=406 AirBase sets, and the LargeGr has a 2 Group of
[AirGroup 2]
StartDate=19401226
EndDate=19420601
Squadron1Class=USFighter
Squadron1No=9
Squadron2Class=LBSUSSearchPlane
Squadron2No=10
Squadron3Class=FBHurricaneMk1
Squadron3No=9
Squadron4Class=LBWhitley
Squadron4No=2
Squadron5Class=USHeavyBomber
Squadron5No=4
Squadron6Class=FBP40Kittyhawk
Squadron6No=4
That is 38 planes altogether, which with the game's logic is about 26 planes too many... :D - when the player's boat is detected in SH4, the AirBase seems to send out all-available, with a bit of an AirStrike.cfg pause between each "send". From what we saw in testing in SH4, a player boat will usually cause the game to generate seven response planes, each round of the AirStrike (whatever that is set to), and they'll show up in grouping of one, two or three airplanes usually, with each grouping on a slightly different heading. btw, SH4 (and 3) has the use of DummyBomb to "fake" the airplane into attacking, and of course, on that DummyBomb attack run, the plane gets close enough to engage with it's machineguns, so it looks like a strafing run. SH5 of course, has the script files to help with that also... :yeah: - so check the cfg file of the LAB_NameAirBaseCountry set of files, and see if the Spitfire and Hurricane might not be over-represented, and probably have to large of a "radius" set for them. Also, there is no such thing as "bingo fuel" to a Silent Hunter airplane... :arrgh!:
www.histoire-en-questions.fr/deuxieme-guerre-mondiale/tragedies-en-mer/atlantique-convois-avions.html
www.avionslegendaires.net/dossier/le-coastal-command/
- so check the cfg file of the LAB_NameAirBaseCountry set of files, and see if the Spitfire and Hurricane might not be over-represented, and probably have to large of a "radius" set for them.
Oh I did, back when I was working on Air Force mod. Not just Spitfires and Hurricanes, but fighters in general are over-represented both in stock SH5 and in TWoS. I also browsed through uboat.net while working on that mod and basically made a list of all documented cases of either plane damaging/sinking a U-Boat or vice versa, and I'm pretty sure many fighter planes present in SH5 never attacked a U-Boat during entire war.
Fixing this, however, requires pretty big edits to campaign air groups and is beyond scope of little AI tweak tested here.
Mister_M
05-03-23, 03:25 AM
I also browsed through uboat.net while working on that mod and basically made a list of all documented cases of either plane damaging/sinking a U-Boat or vice versa, and I'm pretty sure many fighter planes present in SH5 never attacked a U-Boat during entire war.
I would be very interested to see this kind of list. :yep:
I would be very interested to see this kind of list. :yep:
Sure - here's my spreadsheet file, listing planes from the one with most recorded battles with U-Boats to ones with no encounters at all:
https://drive.google.com/file/d/1db9wIBDv51iUBVAQKRn3wDnXQBtL_ktt/view?usp=sharing
As for sources, I used two lists on uboat.net:
1) Aircraft losses to U-Boats:
https://uboat.net/history/aircraft_losses.htm
2) U-Boat losses (these are ordered by year, with cause of loss noted by each boat):
https://uboat.net/fates/losses/
Of course there's a gap in data here - the list doesn't cover battles that didn't result in destruction of either plane or the boat. Still, if a plane didn't score any kills or suffer any losses, one can assume it either wasn't used or was utterly ineffective in this role.
Mister_M
05-03-23, 04:50 AM
Excellent and useful work ! :Kaleun_Applaud:
Thanks a bunch for sharing !
Mister_M
05-23-23, 09:53 AM
Sure - here's my spreadsheet file, listing planes from the one with most recorded battles with U-Boats to ones with no encounters at all:
https://drive.google.com/file/d/1db9wIBDv51iUBVAQKRn3wDnXQBtL_ktt/view?usp=sharing
One remark: actually, a Ventura looks like a Hudson, not a Sunderland...
One remark: actually, a Ventura looks like a Hudson, not a Sunderland...
What my comment means is that in SH5 campaign files, Sunderland 3D model is used to represent Ventura (and Hudson by the way). I added both planes in AirForce mod but stock SH5/TWoS doesn't have them and uses Sunderland in their place.
propbeanie
05-24-23, 01:20 PM
Thanks for the charts kapuhy. Very much appreciated!
If the hit aircrafts could then return to their base immediately, and not come back again and again to attack the sub, that would be a plus...
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.