Log in

View Full Version : Random generation of merchants.


Stiebler
03-21-08, 03:22 PM
From NYGM Research.

The arrival of some 70 new ships onto my SH3 set-up from IABL's New Merchant Fleet has given us the chance to resolve definitively one of the old mysteries of the game:

Does the order in which the ships are loaded (or their alphabetical names) affect how often they are generated when only the type, not the class, is specified in the campaign files?

There are only three rational ways in which the devs would have coded the random selections:

1. A truly random selection. If there are ten candidate ships, then generate a number randomly between 1 and 10 and use the ship randomly found. This represents absolutely basic, stock, coding, and it is hardly likely in fact that the talented devs would even consider any alternative. [A complication is that the devs might have assumed that there would never be more than the original number of merchants in the stock game, so would not allow a random number to be generated greater than that original number.]
2. The devs might provide a deliberate bias, by allowing, let us say, a 10% chance that the first ship encountered will be used. Otherwise, there is a 10% chance that the next ship will be used. Then a 10% chance that the third ship will be used, all the way down the list until the last ship encountered must be taken. This actually results mathematically in a declining probability of a ship being selected. For example, if the probability of the first ship being taken is 10%, the total probability of the second ship is actually 9%, the total probability for the third ship is 8.1%, and the probability of a tenth ship being taken is 3.87%. For this method to work, the ships must indeed be listed in some kind of order of desirability, probably alphabetically.
3. The third possibility is this, the first time a random ship is required, the first is picked from the list (of the ship type, for example, type=102). The second time, the second ship in the list is taken. The third time, the third ship. At some point there has to be a wrap-around of the pointer to start picking the 1st ship on the list again, after the last ship has been used.

I carried out a long IXD2 patrol down to Cape Town and back, full campaign mode, to test whether merchant ships were being generated randomly. The U-boat squatted on the randomly-generated routes for merchants of type=102 (British ships only), and I used all techniques (radar, god's-eye view) to locate them as they passed, changing to a different route each time, before returning to the earlier routes to find re-spawned ships. Thus each ship located was a completely isolated event. No sinking influenced what might appear next.

In total, I found (and sank) nine merchants, in alphabetical order as follows:
1 x L01B, 1 x M01B, 1 x M03B, 1 x M19B, 2 x NKGN, 1 x NKSQ, 2 x S01B. [The double-sunk ships did not appear in quick succession.]

The merchants of type 102 that might have been located on these routes were (in alphabetical order):
L01-L03B (3 ships), M01-M04B (4 ships), M06-M12B (7 ships), M14-M17B (4 ships), M19-20B (2 ships), M35B, NACG, NKGN, NKC3, NKLS, NKSMM, NKSQ, NKSS, NLL, NVV, S01-4B (4 ships).
Total = 34 ships.

It requires no degree in higher mathematics to see immediately that the single ships located by the U-boat appeared virtually randomly from the list of ships of type 102. There is no evidence at all that a list is being worked through, either systematically (option 3 listed above), or randomly (option 2). The statistical chance that at least one ship L01B and at least one S01B could both be encountered within nine ships as in option 2 is around 0.04%.

So we can conclude safely that the devs made the obvious and sensible choice, number (1) above. It is also quite clear that they did *not* restrict their completely random selection between ships to the maximum number already present in stock SH3.

Conclusion:
It doesn't matter how you name new ships added to SH3. They will still be selected completely randomly in the campaign files if only the type and not the class is specified.

[Edit: It would certainly be relevant to have added the *actual* order in which the ships were sunk:
L01B, S01B, KGN, KGN, KSQ, M01B, M19B, M03B, S01A]

Stiebler.

bigboywooly
03-21-08, 03:39 PM
Very interesting Steibler
And in depth as per usual
However I have to say that although I agree with your findings as posted we did have the AMM spawning at a very high rate in GWX 1.0 which is at odds with your findings above
Similary the PRT in tests prior to GWX 2 would appear in a generic convoy multiple times when the game had many many units to choose from
Something I could never understand

Without going into too much detail I wrote a mission with a RND convoy some 500KM away from the uboat and heading towards each other
Now the game would pick multiple instances of the collier and\or the NSCT
Neither have letters beginning before others so was at a loss to understand that

I have also noticed in previous versions of stock\GW\GWX etc that the last units I added tend to crop up more that the ones already there
Unexplainable
Probably ,but when I first added the ore carrier I saw a lot more of those than other unit over many patrols
Was in the WPL at the time so was writing reports and as wasnt a low tonnage unit stood out a fair bit

Interesting all the same though and thanx for the info and indeed the time to do it
Dont get time to play at the mo so my recollections are distant

Stiebler
03-22-08, 04:42 AM
@BBW:

Thanks for your input. I thought you might be interested! Please note I've made a small edit to my original post, to improve clarity.

Your problem with a spawning convoy is certainly a little strange, and seems to defy any explanation. I can only guess that it was a rare statistical fluke. That is the trouble with handling random events. They have to be repeated numerous times to iron out flukes, but you can't guess how many times until you know the width of the problem and the extent of the randomness.

NYGM doesn't use randomly-generated ships in convoys. They are pre-planned in the campaign files. There are two reasons:
1. To ensure that we stay very close to actual Atlantic convoy types, as were originally provided to RUb and NYGM as the 'Improved Convoys Mod' by Jasonb885 (with Sergbuto, for additional ship files), who no longer visits this forum.
2. To ensure quality control. If a user reports a CTD as the U-boat approaches a convoy, we want to be able to recreate the convoy precisely in order to investigate.

Obviously, it is a matter of opinion as to whether this strategy is superior to GWX's alternative preference of having a good random mix every time a convoy is encountered. But it does mean that I have no personal experience of random production of merchants in convoys.

Incidentally, I always enjoy reading your very informed posts, BBW.

Stiebler.

bigboywooly
03-22-08, 06:42 AM
I can certainly see the benefits of a non generic convoy for troubleshooting
That was the reason I ran so many tests on one particular generic convoy to find which ship was causing the problem but I wanted to make it easier for players to add their own ships and do nothing more in terms of the campaign files - as you know yourself making constant minor changes is a PITA and not something the average player will tackle
With the impending release of Iambecomes merchant fleet it makes them just plug and play
Of course that makes Iam's beta testing important to iron out any problems before release as much harder to track down issues

After posting last night I thought I would run some tests myself against a generic convoy and see how much I dropped myself in it :yep:
Made a generic convoy with 5 tankers and 15 merchants all from the Br roster set up in mid 1942
The game can choose between 7 tankers and 13 merchants for that country ( not using Iambecomes shipping ) at that date - The AMM now a type=100 so wasnt going to bump into that

http://i60.photobucket.com/albums/h22/bigboywooly/Percentage.jpg

Interesting findings regarding spawn rates with some ships barely spawning over the 10 tests and others appearing everytime
But no doubt if I ran it another 10 times the results would differ and may do that when have a spare day
:rotfl:

the M11 proved me wrong though as it was the last unit I added and showed up no more or less than any other :oops:
Typical

As to my " informed " posts you are being to kind there
Have always admired your research and wish I could spend as much time in game on it as you have done
Glad to see you are still around too :up:

Stiebler
03-22-08, 10:58 AM
@BBW:

Your excellent table of convoy-spawning data of merchants enabled me to do some standard statistical analysis, counting only the merchants C3Cargo to NSCT (presumably all type=102).

You have listed 13 interchangeable ships, that spawned a total of 150 times. So the mean number of times each ship should have spawned, assuming completely equal chances, is 11.54.

Standard stats (t-test, assuming normal random distribution) predict that each ship would have a better than 90% chance of spawning between 0 and 27.7 times.

However, the lowest number of spawns you got was 5 (C3Cargo) and the highest number of spawns was NSCT (23). These figures are well within the ranges predicted by standard stats.

Therefore your reported convoy distribution is not at all statistically significant (my tables don't go down far enough to give even an approximate figure). Or, to put it another way, you could easily expect such results by chance.

I don't think you have anything to worry about with the spawning of ships in convoys. Besides, it would surely be pretty unusual if the devs used one system of random generation of merchants for single ships, but another for convoys.

I hope that helps.

Also, I take your point about the desirability of a plug-and-play facility for adding new ships randomly to convoys.

Stiebler.