![]() |
SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997 |
![]() |
#61 | |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
Thanks, |
|
![]() |
![]() |
![]() |
#62 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]()
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" ? |
![]() |
![]() |
![]() |
#63 |
Navy Seal
![]() Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
|
![]()
^^^ 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) |
![]() |
![]() |
![]() |
#64 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]()
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. |
![]() |
![]() |
![]() |
#65 | ||
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
Quote:
Code:
unit.crewRating=choice((CrewRating.POOR, CrewRating.NOVICE, CrewRating.COMPETENT)) |
||
![]() |
![]() |
![]() |
#66 |
Navy Seal
![]() Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
|
![]()
Damn.
I wish I knew half of what that was doing, looks pretty interesting, though. |
![]() |
![]() |
![]() |
#67 | |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
![]() 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. |
|
![]() |
![]() |
![]() |
#68 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
mcoca
Thanks for the info ![]() |
![]() |
![]() |
![]() |
#69 |
Navy Seal
![]() Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
|
![]()
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 |
![]() |
![]() |
![]() |
#70 | |
Watch
![]() Join Date: Apr 2007
Posts: 29
Downloads: 0
Uploads: 0
|
![]() Quote:
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. ![]() |
|
![]() |
![]() |
![]() |
#71 | ||
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]() Quote:
![]() |
||
![]() |
![]() |
![]() |
#72 |
Navy Seal
![]() Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
|
![]()
I've been experimenting with a plan towards more accurate (historically) layers. This is very cool indeed.
tater |
![]() |
![]() |
![]() |
#73 | |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]() Quote:
![]() 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 |
|
![]() |
![]() |
![]() |
#74 | |
Watch
![]() Join Date: Apr 2007
Posts: 29
Downloads: 0
Uploads: 0
|
Quote:
![]() 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) |
|
![]() |
![]() |
![]() |
#75 | ||
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]() Quote:
thanks ![]() |
||
![]() |
![]() |
![]() |
|
|