tvwenger / du-factory-generator

https://tvwenger.github.io/du-factory-generator/
MIT License
14 stars 24 forks source link

Implements a new algorithm #62

Closed tvwenger closed 3 years ago

tvwenger commented 3 years ago

With the current algorithm, a large factory is "link limited". The number of industries and containers is limited by the container outgoing link limit, and when that limit is reached the algorithm creates another industry and container. This causes an exponential increase in the number of upstream industries (e.g., smelters and refiners). This algorithm aims to prevent such a situation.

This algorithm has several differences from the previous algorithm:

  1. First, a dependency graph is created. From this we can route the transfer of components.
  2. Industries output their contents to a "dump container". Those contents are then routed via transfer units to "relay containers", where they are collected by other industries.
  3. In some cases, we can merge a dump container and relay container. We need to save these containers as part of the factory, though, so that we can restore them should a change to the factory require a separate dump and relay container.

This algorithm also allows the user to select the requested production rate of the factory outputs rather than the number of producing industries. If the item in question is an intermediate component, the user might not want to dedicate an entire industry to producing the output item. Since we route factory outputs to a relay container, we can support "fractional" industry production of items.

The factory plans produced by this algorithm are still link limited, but instead of having many upstream industries supporting those links, it now has many transfer units supporting those links. The total number of industries + transfer units is nearly the same between this and the previous version.

This PR also updates the UI to support the new algorithm, as well as with some visual enhancements.