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-17-07, 06:25 AM   #61
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by lurker_hlb3
I've found a "bug" when generating "zigzag's" that cross 180 longitude, it will generate positions that go around the world vice crossing the dateline correctly
Yes, that makes sense (I actually sort of considered it would happen, but didn't think it serious). I'll check where the boundary is (in coordinates) and add the appropiate safeguards for 0.4.

Thanks,
mcoca is offline   Reply With Quote
Old 05-18-07, 03:27 PM   #62
lurker_hlb3
Admiral
 
Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
Default

having a problem with "cargoExt & cargoInt". When I use/change them get "error" saying that these item are read only. Was using them in contection with editing / creating merchants.


also


is there code to "randomly" selecting "crewratings" ?
lurker_hlb3 is offline   Reply With Quote
Old 05-18-07, 03:59 PM   #63
tater
Navy Seal
 
Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
Default

^^^ wow, that would be an amazing set of functionality. The ability to pick a number of objects (which it does now) then repopulate some fields with values from a list of possible values randomly.

You can do this after a fashion now by having a few ships of the same type with a % chance of appearing, each with a different crew rating, the only problem being you might very well see ALL of them at once. Sometimes you might want only 1 ship, but of variable skill (or internal/external cargo, etc)
tater is offline   Reply With Quote
Old 05-18-07, 04:07 PM   #64
lurker_hlb3
Admiral
 
Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
Default

Here some test code that I'm working on, it's for Japanese Convoys ( 41a / 42a /42b /43a / 44a / 44b.

I've play test this and some other code for Merchants / TF / SubHunters, and let be the one to tell you, "patrols" are no longer boring


Code:
if group.groupName.find("Convoy") != -1:
    i = group.units.iterator ()
    for unit in i:
        if unit.type == UnitType.CARGO:
            i.remove ()
    i = group.units.iterator ()
    for unit in i:
        if unit.type == UnitType.TANKER:
            i.remove ()
    i = group.units.iterator ()
    for unit in i:
        if unit.type == UnitType.DESTROYER:
            i.remove ()
if group.groupName.find("Convoy") != -1:
   if group.groupName.find("Jap") != -1:
     if group.gameEntryDate.after(Mission.date("19411101")) and group.gameEntryDate.before(Mission.date("19420831")):
     #merchant 1
        mer=RndUnit.createCargo("Japan", 100)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 2
        from random import randint
        padd= randint(65,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 3
        from random import randint
        padd= randint(45,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 4
        from random import randint
        padd= randint(35,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #tanker 1
        from random import randint
        padd= randint(80,100)
        tkr=RndUnit.createTanker("Japan", padd)
        tkr.configurationDate=group.gameEntryDate
        group.units.add(tkr)
if group.groupName.find("Convoy") != -1:
   if group.groupName.find("Jap") != -1:
     if group.gameEntryDate.after(Mission.date("19420831")) and group.gameEntryDate.before(Mission.date("19430831")):
     #merchant 1
        mer=RndUnit.createCargo("Japan", 100)
        mer.number=2
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 2
        from random import randint
        padd= randint(65,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 3
        from random import randint
        padd= randint(45,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 4
        from random import randint
        padd= randint(35,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #tanker 1
        from random import randint
        padd= randint(80,100)
        tkr=RndUnit.createTanker("Japan", padd)
        tkr.configurationDate=group.gameEntryDate
        group.units.add(tkr)
     #tanker 2
        from random import randint
        padd= randint(35,65)
        tkr=RndUnit.createTanker("Japan", padd)
        tkr.configurationDate=group.gameEntryDate
        group.units.add(tkr)
     #escorts
        from random import randint
        padd= randint(75,85)        
        escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, padd)
        escort.configurationDate=group.gameEntryDate
        group.units.add(escort)
if group.groupName.find("Convoy") != -1:
   if group.groupName.find("Jap") != -1:
    if group.gameEntryDate.after(Mission.date("19430831")) and group.gameEntryDate.before(Mission.date("19440531")):
     #merchant 1
        mer=RndUnit.createCargo("Japan", 100)
        mer.number=2
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 2
        from random import randint
        padd= randint(65,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 3
        from random import randint
        padd= randint(45,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 4
        from random import randint
        padd= randint(35,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #tanker 1
        from random import randint
        padd= randint(80,100)
        tkr=RndUnit.createTanker("Japan", padd)
        tkr.configurationDate=group.gameEntryDate
        group.units.add(tkr)
     #tanker 2
        from random import randint
        padd= randint(35,65)
        tkr=RndUnit.createTanker("Japan", padd)
        tkr.configurationDate=group.gameEntryDate
        group.units.add(tkr)
     #escorts
        escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, 100)
        escort.configurationDate=group.gameEntryDate
        escort.crewRating = CrewRating.VETERAN
        group.units.add(escort)
        from random import randint
        padd= randint(75,85)        
        escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, padd)
        escort.number=1
        escort.configurationDate=group.gameEntryDate
        escort.crewRating = CrewRating.VETERAN
        group.units.add(escort)
        from random import randint
        padd= randint(45,85)   
        escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, padd)
        escort.configurationDate=group.gameEntryDate
        escort.crewRating = CrewRating.ELITE
        group.units.add(escort)
if group.groupName.find("Convoy") != -1:
   if group.groupName.find("Jap") != -1:
     if group.gameEntryDate.after(Mission.date("19440530")) and group.gameEntryDate.before(Mission.date("19450831")):
     #merchant 1
        mer=RndUnit.createCargo("Japan", 100)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 2
        from random import randint
        padd= randint(65,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 3
        from random import randint
        padd= randint(45,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #merchant 4
        from random import randint
        padd= randint(35,85)
        mer=RndUnit.createCargo("Japan", padd)
        mer.configurationDate=group.gameEntryDate
        group.units.add(mer)
     #tanker 1
        from random import randint
        padd= randint(80,100)
        tkr=RndUnit.createTanker("Japan", padd)
        tkr.configurationDate=group.gameEntryDate
        group.units.add(tkr)
     #tanker 2
        from random import randint
        padd= randint(35,65)
        tkr=RndUnit.createTanker("Japan", padd)
        tkr.configurationDate=group.gameEntryDate
        group.units.add(tkr)
     #escorts
        escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, 100)
        escort.configurationDate=group.gameEntryDate
        escort.crewRating = CrewRating.VETERAN
        group.units.add(escort)
        from random import randint
        padd= randint(75,85)        
        escort=RndUnit.createWarship("Japan", UnitType.DESTROYER, True, padd)
        escort.crewRating = CrewRating.VETERAN
        escort.configurationDate=group.gameEntryDate
        group.units.add(escort)    


if group.columns > 1:
     group.columns = 2

if group.spacing > 1:
     from random import randint
     group.spacing = randint(500,995)

if group.groupName.find("Convoy") != -1:
   if group.groupName.find("Jap") != -1:
       if group.gameEntryDate.before(Mission.date("19421231")):
           from random import randint
           group.spawnProbability = randint(25,45)
       elif group.gameEntryDate.before(Mission.date("19431231")):
           from random import randint
           group.spawnProbability = randint(35,85) 
       elif group.gameEntryDate.before(Mission.date("19441231")):
           from random import randint
           group.spawnProbability = randint(45,90)
       else:
           from random import randint
           group.spawnProbability = randint(35,50)



if group.repeatIntervalMinutes > 1:
           from random import randint
           group.repeatIntervalMinutes = randint(3000,10000)


if group.autoReportProbability > 1:
           from random import randint
           group.autoReportProbability = randint(5,25)

if group.autoReportInterval > 1:
           from random import randint
           group.autoReportInterval = randint(1440,9999)

if group.columns > 1:
     group.columns = 2

if group.spacing > 1:
     from random import randint
     group.spacing = randint(500,995)

i = group.waypoints.iterator ()
for waypoint in i:
    if waypoint.loopProbability > 0:
        from random import randint
        waypoint.loopProbability = randint(2,8)

i = group.waypoints.iterator ()
for waypoint in i:
    if waypoint.radius > 0:
        waypoint.radius = 0

i = group.waypoints.iterator ()
for waypoint in i:
    if waypoint.length > 500*1852:
        zigZagToWaypoint(waypoint,i,0,100)

i = group.waypoints.iterator ()
for waypoint in i:
    if waypoint.length > 99*1852:
             from random import randint
             angle= randint(15,35)
             distance= randint(12,50)
             zigZagToWaypoint(waypoint,i,angle,distance)

from random import randint
for waypoint in group.waypoints:
    waypoint.speed = randint(7,12)

Last edited by lurker_hlb3; 05-18-07 at 04:22 PM.
lurker_hlb3 is offline   Reply With Quote
Old 05-18-07, 04:42 PM   #65
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by lurker_hlb3
having a problem with "cargoExt & cargoInt". When I use/change them get "error" saying that these item are read only. Was using them in contection with editing / creating merchants.
I expanded the internal names to "internalCargo" and "externalCargo". I have no idea why the error is so silly...

Quote:
is there code to "randomly" selecting "crewratings" ?
Not per se, but it's really easy to create your own:

Code:
unit.crewRating=choice((CrewRating.POOR, CrewRating.NOVICE, CrewRating.COMPETENT))
That will select a random element from that list. Add or remove elements at will. You can also edit init.py to add a function that does that as shorthand.
mcoca is offline   Reply With Quote
Old 05-18-07, 04:44 PM   #66
tater
Navy Seal
 
Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
Default

Damn.

I wish I knew half of what that was doing, looks pretty interesting, though.
tater is offline   Reply With Quote
Old 05-18-07, 04:47 PM   #67
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by lurker_hlb3
Here some test code that I'm working on, it's for Japanese Convoys ( 41a / 42a /42b /43a / 44a / 44b.

I've play test this and some other code for Merchants / TF / SubHunters, and let be the one to tell you, "patrols" are no longer boring.
Wow, those are pretty extensive changes. I have created a monster!

Seeing the kind of things people are doing, next version will definitely have a "run script from file" option. Let's see if I have time to put it together tomorrow.
mcoca is offline   Reply With Quote
Old 05-18-07, 06:13 PM   #68
lurker_hlb3
Admiral
 
Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
mcoca

Thanks for the info
lurker_hlb3 is offline   Reply With Quote
Old 05-18-07, 06:20 PM   #69
tater
Navy Seal
 
Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
Default

I don't suppose you could remark that code for a slacker like me to try and figure out exactly what's going on. I can see much of it, but that one huge sample marked up would be an invaluable learning tool.

<S>

tater
tater is offline   Reply With Quote
Old 05-18-07, 06:49 PM   #70
Yanaran
Watch
 
Join Date: Apr 2007
Posts: 29
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by tater
I don't suppose you could remark that code for a slacker like me to try and figure out exactly what's going on. I can see much of it, but that one huge sample marked up would be an invaluable learning tool.

<S>

tater
It's not as complicated as it might look. Most of the size is because he's got a separate if statement for every thing he wants to change, no doubt because he started out doing one change and testing, then adding another change and testing, etc.

First he clears out all convoys of ships, then adds them back depending on the date. Few ships and no escorts in the beginning, then more ships and more escorts as the war progresses.

After that he changes the shape of the convoys by randomizing the separation between ships and limiting the number of columns. He also reduces and randomizes the spawn probability of each convoy to what I think most would consider more realistic chances (less in the beginning, then more, and in the end less again). Then he lowers and randomizes report probability, randomizes "respawn interval" and "report interval".

Then he changes the convoys shape again to the same as he changed above. :p (probably accidental copy/paste hehe)

At the end he's creating zig-zags by removing the radius of "random waypoints" and splitting them up in 500nm segments. You have to remove radius on waypoints for zigzags to work right or ships will travel very strange paths. Each segment is then turned into a random zig-zag pattern and finally the speed on each waypoint is randomized.
Yanaran is offline   Reply With Quote
Old 05-18-07, 07:03 PM   #71
lurker_hlb3
Admiral
 
Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
Default

Quote:
Originally Posted by Yanaran
Quote:
Originally Posted by tater
I don't suppose you could remark that code for a slacker like me to try and figure out exactly what's going on. I can see much of it, but that one huge sample marked up would be an invaluable learning tool.

<S>

tater
It's not as complicated as it might look. Most of the size is because he's got a separate if statement for every thing he wants to change, no doubt because he started out doing one change and testing, then adding another change and testing, etc.

First he clears out all convoys of ships, then adds them back depending on the date. Few ships and no escorts in the beginning, then more ships and more escorts as the war progresses.

After that he changes the shape of the convoys by randomizing the separation between ships and limiting the number of columns. He also reduces and randomizes the spawn probability of each convoy to what I think most would consider more realistic chances (less in the beginning, then more, and in the end less again). Then he lowers and randomizes report probability, randomizes "respawn interval" and "report interval".

Then he changes the convoys shape again to the same as he changed above. :p (probably accidental copy/paste hehe)

At the end he's creating zig-zags by removing the radius of "random waypoints" and splitting them up in 500nm segments. You have to remove radius on waypoints for zigzags to work right or ships will travel very strange paths. Each segment is then turned into a random zig-zag pattern and finally the speed on each waypoint is randomized.
right on the mark Yanaran, this code is in a "beta" work stage. After I fine tune it I'll add comments for each section of code.
lurker_hlb3 is offline   Reply With Quote
Old 05-18-07, 09:28 PM   #72
tater
Navy Seal
 
Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
Default

I've been experimenting with a plan towards more accurate (historically) layers. This is very cool indeed.

tater
tater is offline   Reply With Quote
Old 05-18-07, 10:38 PM   #73
lurker_hlb3
Admiral
 
Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
Default

Quote:
Originally Posted by tater
I've been experimenting with a plan towards more accurate (historically) layers. This is very cool indeed.

tater
I hear you. Reviewing all the different layer for the Japanese and you can see it just the same old thing over and over. after playing them for a while, you know excatly what speed their traveling and their not going the maneuver, "BORING"

During some of my play testing with the code I posted early, you have to stay on your toes "all" the time. The conveys will maneuver when you least expect it and you "will" have to recompute your setup.

Have been do some research to attempt to create layer that will be as close to real world as possible within the confines of SH4

lurker_hlb3 is offline   Reply With Quote
Old 05-19-07, 07:04 AM   #74
Yanaran
Watch
 
Join Date: Apr 2007
Posts: 29
Downloads: 0
Uploads: 0
Quote:
Originally Posted by lurker_hlb3
I hear you. Reviewing all the different layer for the Japanese and you can see it just the same old thing over and over. after playing them for a while, you know excatly what speed their traveling and their not going the maneuver, "BORING"
If I can just make one suggestion, it would be that you don't need to go overboard with the random numbers everywhere.

For instance when you recreate your convoys, there's no need to randomize the "padd" number that represents spawn probability for the ship created. If you create 4 ships all with random spawn probability, you'll still get 0-4 ships in the convoy just as if you created them with set probabilities of say, 80 60 40 20% each. You won't be able to tell the difference between a convoy created with those settings and one created with, say, 75 36 54 49% that you might get from your random probabilities. Just a suggestion to shorten down your code hehe.

Also about randomizing speed on the waypoints, I highly recommend doing it after you've split up the paths in 100nm segments and before creating zigzags. The reason beaing that the game is already poor at maintaining formation in zig-zag turns and if you alter speed in the turns it gets even worse. It would look something like this

Code:
from random import randint
i = group.waypoints.iterator ()
for waypoint in i:
    if waypoint.loopProbability > 0:
        waypoint.loopProbability = randint(2,8)
    if waypoint.radius > 0:
        waypoint.radius = 0
    if waypoint.length > 500*1852:
        zigZagToWaypoint(waypoint,i,0,100)
for waypoint in i:
    waypoint.speed = randint(7,12)
    if waypoint.length > 99*1852:
             angle= randint(15,35)
             distance= randint(12,50)
             zigZagToWaypoint(waypoint,i,angle,distance)
Yanaran is offline   Reply With Quote
Old 05-19-07, 08:25 AM   #75
lurker_hlb3
Admiral
 
Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
Default

Quote:
Originally Posted by Yanaran
Quote:
Originally Posted by lurker_hlb3
I hear you. Reviewing all the different layer for the Japanese and you can see it just the same old thing over and over. after playing them for a while, you know excatly what speed their traveling and their not going the maneuver, "BORING"
If I can just make one suggestion, it would be that you don't need to go overboard with the random numbers everywhere.

For instance when you recreate your convoys, there's no need to randomize the "padd" number that represents spawn probability for the ship created. If you create 4 ships all with random spawn probability, you'll still get 0-4 ships in the convoy just as if you created them with set probabilities of say, 80 60 40 20% each. You won't be able to tell the difference between a convoy created with those settings and one created with, say, 75 36 54 49% that you might get from your random probabilities. Just a suggestion to shorten down your code hehe.

Also about randomizing speed on the waypoints, I highly recommend doing it after you've split up the paths in 100nm segments and before creating zigzags. The reason beaing that the game is already poor at maintaining formation in zig-zag turns and if you alter speed in the turns it gets even worse. It would look something like this

Code:
from random import randint
i = group.waypoints.iterator ()
for waypoint in i:
    if waypoint.loopProbability > 0:
        waypoint.loopProbability = randint(2,8)
    if waypoint.radius > 0:
        waypoint.radius = 0
    if waypoint.length > 500*1852:
        zigZagToWaypoint(waypoint,i,0,100)
for waypoint in i:
    waypoint.speed = randint(7,12)
    if waypoint.length > 99*1852:
             angle= randint(15,35)
             distance= randint(12,50)
             zigZagToWaypoint(waypoint,i,angle,distance)



thanks
lurker_hlb3 is offline   Reply With Quote
Reply


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 08:01 PM.


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