2TallTyler / improved_town_industries

An industry replacement set for OpenTTD.
GNU General Public License v3.0
22 stars 17 forks source link

Strange clustering of some industries #50

Closed LeafyLappa closed 3 years ago

LeafyLappa commented 3 years ago

I think I might have come across a bug.

I made a game script that pretty much fills a rectangle around any given industry with industries of the same type.

This is what happens when I run it with vanilla industries:

Unnamed, Jun 15th, 1973

When I run it with improved town industries, some industries will be created at maximum possible distance within the rectangle, not filling it. Examples that I noticed are forest, farm and coal mine.

This seems to be intended behavior in improved town industries as (if I'm not mistaken) it aims to create clusters of raw industries (and changes game logic regarding processing industries too) over the course of the game. However...

Oldenbrück Transport, Sep 24th, 1973

Uranium mines, iron ore mines and oil wells spawn normally, meaning either improved town industries does not have any logic for their distancing or this feature has a bug and won't work with those three. Is this by design?

James103 commented 3 years ago

Can you post the code for the Game Script so others can take a look?

LeafyLappa commented 3 years ago

Sure, this is the code I ran when I took those two screenshots: https://github.com/Greentaily/WideIndustriesGS/blob/main/main.nut

Methods EndOfMonth(), GrowIndustry() and map_list().

James103 commented 3 years ago

What versions of OpenTTD and Improved Town Industries were you running?

LeafyLappa commented 3 years ago

jgrpp 0.39.0 and improved town industries 1.6.0

LeafyLappa commented 3 years ago

Here's another screenshot to better illustrate it.

Unnamed, Aug 29th, 1971

It looks like improved town industries puts a restriction on how close naturally spawned coal mines can be, but not uranium mines.

2TallTyler commented 3 years ago

Hello,

You're correct that there are a lot of industry location checks in ITI. If you want to peruse the rules yourself, they're reasonably well commented in src/[industry_name].nml for each industry.

There is no restriction on coal mines spawning close to each other, so I'm not sure what's happening there. Forests do have a rule against spawning near each other, and all industries won't build within 30 tiles of a farm to avoid building in a field.

That said, reading through my code to answer your questions has made me realize that I've created a tangled mess full of unnecessary code. I'm going to take some time this holiday weekend to do a major simplification and push a 1.7.0 release.

What I plan to keep will be:

What I'm on the fence about keeping or eliminating (suggestions welcome):

What I'm definitely cutting (in case you spot them reading through code):

Questions for you:

Another thought: ITI includes objects of each industry tile to visually expand industry areas. I wonder if a gamescript could place these automatically near high-production industries to accomplish the same effect without the player having to worry about catchment areas.

LeafyLappa commented 3 years ago

Thank you for investigating into the issue :smile:

Regarding clustering of mines, it was definitely noticeable in my longer games on 1024x1024 grid. Sometimes I would have five mines in one station's catchment area, and there would be more mines nearby, served by other stations, despite low number of industries game setting. (I'm usually playing with a very low day length factor so the amount of cargo is still manageable)

Do you want secondary industries to also grow near each other? (I could add a parameter for the competitor distance check)

Yes but it's optional in my game script, it does not seem to integrate well into the game and after skimming GSAPI I don't even think it's possible to place landscape objects that way. I'm not sure if such thing in my script is enough to prompt a change in improved town industries with its rules.

ITI includes objects of each industry tile to visually expand industry areas. I wonder if a gamescript could place these automatically near high-production industries to accomplish the same effect without the player having to worry about catchment areas.

The game script documentation has nothing on placement of landscape objects unfortunately, so I believe it's not possible.

Since I'm reworking location check rules already...any thoughts or requests?

One thing that I enjoyed in my games was joint placement of town industries. I would start the game as early as 1830 and grow a city. Sometimes, the city would then build steel mill, paper factory and / or recycling center directly adjacent to its already existing factory without any tiles in between. One time I even had three of them placed that way. I'm not sure whether that is intended or I'm just lucky like that, but it could be a feature: heavy traffic industrial zones within cities. In my country, urban planning has been like that for over a century now I believe.

2TallTyler commented 3 years ago

Thanks. I think one big difference in our experiences with clustering is the "multiple industries per town" setting. I have it off, as is the default, so I rarely get two of the same industry very close to each other, as only one is allowed per town and the owning town is controlled by the distance to the town origin tile. Any clustering mechanic is barely noticeable on my game settings.

Your suggestion of what I'd call "industrial zones" is intriguing. I'll have to experiment with this.

2TallTyler commented 3 years ago

I've made these changes and a few more (including the industrial zones you suggested). I'd love any feedback on the 1.7.0 beta release: https://github.com/2TallTyler/improved_town_industries/releases/tag/1.7.0_beta

LeafyLappa commented 3 years ago

Some notes:

I might not have the time to do a complete playthrough in the next few days but the changes look very enticing!

2TallTyler commented 3 years ago

Thanks for your thoughts.

You're probably right about cargo decay rates. I've been using the in-game cargo payments graph to balance cargos, but comparing the slope of a line across industry sets just by looking at it is probably impossible. The best solution here may be to leave decay rates alone...

With passengers I'd forgotten that you generally make money on both legs of the journey, so it should be be priced at half the intended value.

I played a fun test session yesterday where I actually had to watch my pennies for longer than simply building the initial route. My wood trains to a Sawmill were making only modest profits so I had to be more careful than usual. That said, I started in 1980 with relatively fast, high-capacity trains. The real test will be whether I can survive an early start with horse-drawn road vehicles and Sailing Ships.

The balance shift is intentional and is designed to push players toward moving secondary and tertiary products like Lumber, Steel, and Goods. You won't get rich just delivering a river of primary products like Wood, but you will make enough to build the next step of the chain where the real profit is found. The trick here is making sure early games are still possible and fun (see above) and that new players won't bankrupt themselves too easily with inefficient routes.

I can definitely add a parameter for industrial zones, but I'm not sure it's necessary. I'll have to do some more testing to find any side effects which players may want to disable. Increasing the range may help, too.

2TallTyler commented 3 years ago

The beta download is updated with these changes. So far, so good with my early start test!

2TallTyler commented 3 years ago

I released 1.7.0 tonight, so I'm going to close this issue. If you have further questions or concerns, feel free to re-open and we can continue discussing. :)

LeafyLappa commented 3 years ago

Yep, sorry, a few days turned into a few weeks, can't get enough time these days. Can't wait to see how industrial zones affect longer games!