News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

factory input/output: distinguish between primary and secondary goods

Started by Leartin, May 04, 2017, 09:58:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Leartin

Say a pak developer creates a normal factory chain, like [woodcutter]--(logs)->[sawmill]--(planks)-> [some consumer]. Everything is fine.
Now you get the idea that sawmills create sawdust as a byproduct, which could be used in a pillow factory. So you add sawdust as output for the sawmill, allow a pillow factory to consume it and start a map. What happens? Why of course you get a chain consisting of a woodcutter, a sawmill and a pillow factoy, and no consumer for planks. Which means the sawmill became a woodgrinder with the sole purpose of producing sawdust, even though it was intended as a side product.


I'd like to be able to mark both inputs and outputs of a factory as secondary.
If an input is secondary, it means that this good is not required for the factory to work. No producer for this good is required to spawn with this factory, either. Essentially, if an input is secondary, it is treated as if the factory was an end consumer.
If an output is secondary, it means this factory will not spawn as a result of a consumer that requires this product.

If you think this could mean that a lot of chains are incomplete - yes, possibly, if pak creators don't use this with care. For example, if you created a pillow factory and a sawmill with sawdust as secondary output, the power plant will not cause the sawmill to spawn. Unless there is already a sawmill on the map, a pillow factory would not be possible. Except if you add a geese farm for the sole purpose of producing feathers, which would be the primary input of the pillow factory, while sawdust is a secondary input. Thus, when the pillow factory spawns, it would spawn with at least one geese farm (which would be required) and then it would check if there is already a sawmill around which could provide sawdust. If not, the chain works anyway.


Since a secondary input is not required for a factory to work, if there is only a secondary input, the factory will act as if it was a pure producer.
Since a secondary output should never be the reason for a factory to exist, a factory that only has secondary outputs can spawn like an end consumer.




For Players, the gain would be that there would be optional connections. We usually tell beginners to start with a coal mine to power plant route, because it's so simple, but because it is so simple, it becomes rather boring and meaningless quickly. However, if the coal mine had secondary inputs - eg. logs for support - one could come back later and expand on the chain. I always felt that longer, more complicated chains make the game more fun. However, the longer and more complicated the chain, the higher the chance a part of it is missing.

For Pak Devs, the gain would be more freedom in factory creation, especially in regards to end consumers. For example, the prison in p192c is an end consumer. I think it would be funny if it produced stone and consumed dry bread. But that would combine the chains, so all of them would only spawn if a stone consumer spawns, and all of them must be transported from/to for the chain to work. With secondary in- and outputs, the bakery could be an end consumer and still provide bread for the prison, and if a prison exists, a construction chain could get stones from it, but if it does not exist, the construction chain would get stone from a regular stonefield.

For the Game Code, I don't think it really makes anything better, but I believe it would not be worse this way. Rather, it seems to be easy compared to other suggestions made in this field.

DrSuperGood

QuoteIf an input is secondary, it means that this good is not required for the factory to work. No producer for this good is required to spawn with this factory, either. Essentially, if an input is secondary, it is treated as if the factory was an end consumer.
Not too easy to implement. What effect on factory production power should secondary productions have? Or does a secondary input mean pretty much that the stuff is thrown in a huge fire and burnt like an end consumer? How does one meter the ordering of secondary product?

QuoteIf an output is secondary, it means this factory will not spawn as a result of a consumer that requires this product.
Would require changing the factory spawn logic. As it is factory spawn logic is pretty bad so I would imagine this being a worth while addition when it is revised.



Flemmbrav

QuoteNot too easy to implement. What effect on factory production power should secondary productions have? Or does a secondary input mean pretty much that the stuff is thrown in a huge fire and burnt like an end consumer? How does one meter the ordering of secondary product?
Well, that pretty much could be left to the Pak Devs. I'ld love to have it treaten as the energy or worker bonusses we already do have.
So Leartin could decide that the prisoners work harder when they have something to eat so they produce more stones. Or maybe they don't because they waste the amount of stones they produce with taking breaks so in the end it adds up to the same amount as without bread.

Ters

Quote from: Flemmbrav on May 04, 2017, 03:45:50 PM
Well, that pretty much could be left to the Pak Devs.

That means that developers have to code all options, which reduces the likelihood that they will bother doing anything at all.

Flemmbrav

So there is a likehood? that's nice!

I was not imagining that it would be hard to have a multiplier in it whichs default is 1. But that small part of the request - if it even is one - shall not hinder anyone coding it. It's the other way around, I'ld love to see a patch for it and if there is a problem finding a solution for what DrSuperGood pointed out I'll try my best to find a way which in my opinion seems to be a good way to solve it.

Leartin

Quote from: DrSuperGood on May 04, 2017, 02:51:18 PM
What effect on factory production power should secondary productions have? Or does a secondary input mean pretty much that the stuff is thrown in a huge fire and burnt like an end consumer?
I suppose at a later point, they could be used to provide a boost in productivity similar to pax, post and electricity. But as a first step, yes, they would simply be used without doing anything, like an end consumer.
For example, imagine a botteling factory which requires bottles/glass as a primary good and produces beverages. It could then require berrys, lemons, apples,... as secondary goods. The explaination would be that if only bottles/glass are provided, the resulting beverage would be water. If the factory gets berrys or apples delivered, it would produce juice. If it gets lemons delivered, it would produce lemonade. But for you as transportation company, it does not really matter what kind of beverage gets produced, as it would not change the transportation fee.

A different example would be with the aforementioned prison. Currently, it's just the end consumer for criminals. That's fine, and within the realm of the game, it does not cause any questions. But if it would consume some kind of food, like bread, it would not be out of place either. However, the way it is right now, if the prison would consume bread, it might spawn just to consume bread, without the actual prison chain, which is certainly not intended. Since it's an end consumer anyway, it does not matter that the secondary input has no influence on productivity.

Quote from: DrSuperGood on May 04, 2017, 02:51:18 PM
How does one meter the ordering of secondary product?
The same as the primary product. Each factory has a productivity rate, which tells you how many units per month it will use up/produce, with optional rates for each individual input or output in percentage. Reusing the botteling factory example: For each unit of beverage, you require one unit of primary input bottles. (both 100%). If you use berrys, you use up one unit of berry every four units of beverage (25%). You cannot deliver too little amount of berrys, since the factory will just bottle water instead. You could deliver too many, which would mean the botteling plant would stop ordering them. Since beverages are only produced while bottles are provided, delivering berrys without bottles would just fill the input storage.

Quote from: DrSuperGood on May 04, 2017, 02:51:18 PM
Would require changing the factory spawn logic.

Are you sure it's a big change? I'd imagine the end consumer is decided by chance, then it looks at which factories produce what it needs, and plants those depending on their chance level. So in this bit of code, you would need an additional check whether it's produced as a secondary output, and if so, don't add it to the pool of potential producers. Obviously, different behaviour requires a bit of new code, but this suggestion is intentionally trying to require as little change as possible to what is already established.

prissi

The factory builder has already a hard time to balance production with demand for mandatory goods. That was already not too easy with in the constrains (like a finite time for a new chain) and some factories producer numbers set in the files and other left to automatic. Not to mention production boosts. This is unlikely to become any better with a more complex system.

Also chain spawn one end consumer good after the other. Liek the Pharmacetical chain in pak64 first with create a chemical chain and onext the mecial chain.