SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH4 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 05-13-07, 06:56 AM   #31
Yanaran
Watch
 
Join Date: Apr 2007
Posts: 29
Downloads: 0
Uploads: 0
Default

Yes, concurrentyadayada that's it

Your workaround seems to work, I was trying to figure it out using the iterator but didn't think to try i.remove() hehe.
Yanaran is offline   Reply With Quote
Old 05-13-07, 06:59 AM   #32
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by Yanaran
Yes, concurrentyadayada that's it

Your workaround seems to work, I was trying to figure it out using the iterator but didn't think to try i.remove() hehe.
I had the same problem inserting the zigzagging waypoints, that's why I knew the solution You should see the hack I had to do to insert a waypoint before the current one (actually, it's in init.py)...
mcoca is offline   Reply With Quote
Old 05-13-07, 08:19 AM   #33
Yanaran
Watch
 
Join Date: Apr 2007
Posts: 29
Downloads: 0
Uploads: 0
Default

I have a suggestion for the zigzagging.

I've tried a few zigzags on the convoy files and checked the results in the mission editor. I notice that there are often problems with the final zig, especially if the waypoint at the end is near land. What happens is that if the last zig is almost as long as the distance to the "end waypoint", you'll end up almost at a 90 degree angle to the final waypoint and if it's close to shore odds are you'll end up with a waypoint that's on land. For example try the example from the readme on the 41a_jap_convoys and look at the waypoints just outside Manila.

So my suggestion would be that instead of creating zigzags all the way to the waypoint, stop zigging one step earlier so the last leg will be between 1 and 2 "distance" instead of between 0 and 1.

I *think* this change to init.py will fix it:

In zigZagToWaypoint(waypoint,iterator,offset,distance ) change

Code:
for x in range(0,zigSteps(waypoint, offset, distance)):
to
Code:
for x in range(0,zigSteps(waypoint, offset, distance)-1):
I've tried it and it looked better on the manila waypoint I talked about above, but I'm no expert in python so I don't know if it breaks something else.
Yanaran is offline   Reply With Quote
Old 05-13-07, 08:54 AM   #34
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by Yanaran
I've tried a few zigzags on the convoy files and checked the results in the mission editor. I notice that there are often problems with the final zig, especially if the waypoint at the end is near land. What happens is that if the last zig is almost as long as the distance to the "end waypoint", you'll end up almost at a 90 degree angle to the final waypoint and if it's close to shore odds are you'll end up with a waypoint that's on land. For example try the example from the readme on the 41a_jap_convoys and look at the waypoints just outside Manila.
You are right, it looks bad. Automated changes can do a lot, but they are not magic (yet ), so that's why you should always check the resulting file.

Quote:
So my suggestion would be that instead of creating zigzags all the way to the waypoint, stop zigging one step earlier so the last leg will be between 1 and 2 "distance" instead of between 0 and 1.
That fixes the last zig-zag What about the first? The same problem applies... maybe the long term solution would be to include a "safety zone" around the end points of the zig-zag.

Quote:
In zigZagToWaypoint(waypoint,iterator,offset,distance ) change

Code:
for x in range(0,zigSteps(waypoint, offset, distance)):
to
Code:
for x in range(0,zigSteps(waypoint, offset, distance)-1):
I've tried it and it looked better on the manila waypoint I talked about above, but I'm no expert in python so I don't know if it breaks something else.
That works, and I'll include it in the next release, unless we comeup with a better solution for the beginning of the zig-zag.

Thanks!
mcoca is offline   Reply With Quote
Old 05-13-07, 05:06 PM   #35
Yanaran
Watch
 
Join Date: Apr 2007
Posts: 29
Downloads: 0
Uploads: 0
Default

Well, let me know if you figure out how to get zig-zags to play nice with random waypoints.

I can't decide if I want to keep the random waypoints or have all convoys follow a precise path but doing zig-zags. As much as I want the convoys to zig-zag I don't want them to pass the exact same spots over and over again, I just know I'd end up "cheating".
Yanaran is offline   Reply With Quote
Old 05-13-07, 05:22 PM   #36
tater
Navy Seal
 
Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
Default

There is anoother way to create "random" zig zag paths.

Use the loop functionality. There is a FAQ about making alternat paths with it. Have waypoints 2 to X be zig zag along a path. Have waypoint X+2 start next to waypoint 2 itself. Waypoints X+2 to Y are a zig zag on an alternate path. Have waypoint X+1 have a 100% loop to waypoint Y.

You now have 2 alternating zig zag paths. Set the % chance of this convoy at 10% of what you want to see.

Take this convoy or merchant group, then perhaps the program could be used to clone it, with every single waypoint offset a few kilometers in one direction. Make 10 such clones. You now have a cloud of alternating zigzags each with a 10% chance of happening, but you have 10 of them. Offset the start times, etc to minimize the chances of 2+ at once.

That might work, anyway.

Alternatly, you could make a cloud of such alternating paths within the same group. Just set a bunch of waypoints before the first zigzag to give many chances of alternate paths that are side by side within a few km.
tater is offline   Reply With Quote
Old 05-13-07, 06:18 PM   #37
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

I agree, it's a tough decision between zigzags and random routes. Looping will work, but in its current incarnation the zigzagging code doesn't really support loops. They will be maintained, but the ships will not zigzag along the alternative route.

This is one of those frustrating problems: we can spend months finding a kludge that almost works, but makes the campaign files ten times bigger. But the devs can probably code zigzagging into the AI in a few hours at most.

Today I discovered http://dangerdeep.sourceforge.net/ an open source subsim in the early phases of development (it already looks pretty, though). I really hope they get it working... the things we could do with it.
mcoca is offline   Reply With Quote
Old 05-13-07, 06:57 PM   #38
Yanaran
Watch
 
Join Date: Apr 2007
Posts: 29
Downloads: 0
Uploads: 0
Default

Well I just finished my first patrol with all convoy routes replaced with zigzagging waypoints (I set all waypoint.radius = 0) and I loved it. For the first time in weeks I missed an entire spread when I fired precisely at the "wrong" moment from about 7000yards out (mk16 torps).

The convoy turned 40 degrees to port when the torpedoes where about 1/3 on their way and they all missed by what felt like miles. It might be easier to find convoys like this, but it's definatly harder to get the kills. I don't know what would be realistic settings for the zig-zags but I used 20degrees and 10miles like your example script.
Yanaran is offline   Reply With Quote
Old 05-13-07, 09:57 PM   #39
tater
Navy Seal
 
Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
Default

mcoca,

What about the ability to cut and paste after a fashion? Not just the unit, but a group of waypoints?

I might make a screenshot to show you what I mean.

tater
tater is offline   Reply With Quote
Old 05-13-07, 11:53 PM   #40
tater
Navy Seal
 
Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
Default

Is it possible to make it apply the zig-zags only between certain pairs of waypoints for a group?

I make a convoy sail from Tokyo Bay to Truk. I make a series of waypoints to get them to the open ocean, say 6. Waypoint 7 is near Truk.

I then make waypoint 8 all the way back next to 6. 9 is next to Truk, but offset from 7. 10 is back near 6/8. 11 near Truk, etc.

I'd have the campaign editor then make zi-zags only between waypoints 6-7, 8-9, 10-11, 12-13, 14-15. I now have 5 zig-zags from near Tokyo to near Truk. I could do 20 if I wanted 5km apart and I'd have a 100km swath.

I'd set all of the "near Truk" waypoints (numbers would change since you'd add the zig-zags between) to 100% loop to the very last waypoint for the group, AT Truk. Some of the very first open ocean waypoints would then have a loop % to one of the alternate routes.

I tested this, and it works, I can add as many alternate routes for 1 group as I like. If a program could do the zig-zags between waypoint pairs of my choosing it's make it really easy.

I agree that it would be better if the devs just coded the game correctly instead though.
tater is offline   Reply With Quote
Old 05-14-07, 03:13 AM   #41
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

tater,

About copy/paste, do you mean copying the entire route from one group to another? Yes, it's possible, with limitations: you cannot alter the routes after copying in the same run of the program, and you cannot insert just some waypoints. This can be fixed in new versions, though. I can show you code if you tell me exactly what you want.

I see what you mean with loops. You can zigzag some waypoints and no others, but you need to "tag" the zigzagging ones in some way. I suggest giving them a random radius, then removing it in the same change, like this:

Code:
i = group.waypoints.iterator ()
for waypoint in i:
    if waypoint.radius > 0
        waypoint.radius = 0
        zigZagToWaypoint(waypoint,i,20,10)
You could even choose what zigzag you want by setting the radius to a given value. For example, this will make a radius of 10.20 to be interpreted as "zigzag ten miles, offset 20 degrees" (untested, so be careful about it):

Code:
i = group.waypoints.iterator ()
for waypoint in i:
    if waypoint.radius > 0
        # extract distance & convert to meters
        distance=int(waypoint.radius)*1852
        angle=(waypoint.radius-int(waypoint.radius))*100
        zigZagToWaypoint(waypoint,i,angle,distance)
        waypoint.radius = 0
mcoca is offline   Reply With Quote
Old 05-14-07, 06:14 AM   #42
Yanaran
Watch
 
Join Date: Apr 2007
Posts: 29
Downloads: 0
Uploads: 0
Quote:
Originally Posted by tater
Is it possible to make it apply the zig-zags only between certain pairs of waypoints for a group?
Maybe I misunderstand what you want to do, but from your description it sounds like the suggestion in the readme with a distance check would work? Make the distance check extra long to make sure you only get it on the 6-7, 7-8 etc legs.

for 500nm:
Code:
if waypoint.length > 500*1852:
    zigZagToWaypoint(waypoint,i,20,10)
I used 100nm when I tried on the stock convoy files, but 500 should ensure you only get it on very long waypoints.
Yanaran is offline   Reply With Quote
Old 05-14-07, 08:36 AM   #43
tater
Navy Seal
 
Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
Default

^cool. that should do. i will make an example to show you exatly what i mean. The goal might be to automate the process somehow.
tater is offline   Reply With Quote
Old 05-14-07, 11:07 AM   #44
tater
Navy Seal
 
Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
Default

OK, I'm semi-clueless here.

I have a mission to test. I have it set under Input.

Under Group conditions I have:

i = group.waypoints.iterator ()
for waypoint in i:
# 400 * 1852 is 400 NM in meters.
if waypoint.length > 400*1852:
zigZagToWaypoint(waypoint,i,20,4.5)

It gives a syntax error (I just copied the example in the readme and altered the numbers a little).
tater is offline   Reply With Quote
Old 05-14-07, 11:16 AM   #45
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by tater
Under Group conditions I have:

i = group.waypoints.iterator ()
for waypoint in i:
# 400 * 1852 is 400 NM in meters.
if waypoint.length > 400*1852:
zigZagToWaypoint(waypoint,i,20,4.5)

It gives a syntax error (I just copied the example in the readme and altered the numbers a little).
It needs to be in group change. Group condition is to filter the groups (saving you an 'if' statement), and must be either empty or a true/false statement

Also, I'm guessing it's because you didn't put code tags around the example, but just in case, spacing matters in python, so make sure what's inside the if and for statments is indented beyond them.
mcoca is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.