Then I've patched OpenTTD myself in the past to halve the passenger generation, but then I noticed that small villages are no longer fun. So I had a patch in the past where I checked t->cache.population if it was below 300, that somewhat fixed my problem.

*BUT* - here comes the plot twist.

Passenger and mail cargo generation was and is broken in OpenTTD!

Let me show you one screenshot first where I've tried to find good examples of the bug in-game:

Sentbridge has 800 citizens while Slonnley has 269. We would expect Sentbridge to have about three times as many passengers (800 / 269), but in reality it has 20 times as many!

Why is this?

Code: Select all

```
if (GB(r, 0, 8) < hs->population) {
uint amt = GB(r, 0, 8) / 8 + 1;
```

This is the code to generate the amount of passengers. It uses the house population twice and accidently causes quadratic growth of generated passenger amount!

In the example Slonnley has houses with mostly 13 and 30 inhabitants while big cities after some game-time have mostly houses with up to 180 inhabitants.

We would expect that a house with 30 inhabitants generates about 2.3 times (30/13) as many PAX as the house with 13 inhabitants.

And finally we would expect that a house with 180 inhabitants generates 13.85 times as many PAX as the house with 13 inhabitants (180/13) and 6 times (180/13) as many PAX as the house with 30 inhabitants.

Right?

Now let me show you what really happens when you put these numbers into the algorithm:

13 inhabitants = 13/256 chance to generate 1-2 PAX (minimum: floor(0/8) + 1, maximum: floor(12/8) + 1)

=> a 13-inhabitant-house generates 0.076 PAX on average every call.

Now our expectation for a 30-inhabitant-house is 0.175 (0.076 * 30 / 13) PAX -- let's see:

30 inhabitants = 30/256 chance to generate 1-4 PAX (minimum: floor(0/8) + 1, maximum: floor(29/8) + 1)

=> a 30-inhabitant-house generates 0.293 PAX on average every call. This is nearly the double our expectation!

Now our expectation for a 180-inhabitant-house is 1.052 PAX based on 13-inhabitant-house (0.076 * 180 / 13) and 1.758 PAX based on the already higher 30-inhabitant-house (0.293 * 180 / 30) -- let's see:

180 inhabitants = 180/256 chance to generate 1-23 PAX (minimum: floor(0/8) + 1, maximum: floor(180/8) + 1)

=> a 180-inhabitant-house generates 8.438 PAX on average every call. This is 8 times higher than expected based on 13-inhabitant-house and 4.8 times higher than expected based on 30-inhabitant-house

CONCLUSION

A house with 14 times as many inhabitants (180:13) generates 111 times as many PAX and mail!!

patches in next post

kind regards,

Kira