News:

SimuTranslator
Make Simutrans speak your language.

Question about industry spacing

Started by jamespetts, December 01, 2012, 02:42:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamespetts

The code as currently written uses the factory_spacing setting to make an exclusion zone around every factory on generation, with the effect that the parameter dictates the minimum spacing between any factory and any other, as in this code:


// marks factories with exclusion region in the position map
static void add_factory_to_fab_map(karte_t const* const welt, fabrik_t const* const fab)
{
    koord3d      const& pos     = fab->get_pos();
    sint16       const  spacing = welt->get_settings().get_factory_spacing();
    haus_besch_t const& hbesch  = *fab->get_besch()->get_haus();
    sint16       const  rotate  = fab->get_rotate();
    sint16       const  start_y = max(0, pos.y - spacing);
    sint16       const  start_x = max(0, pos.x - spacing);
    sint16       const  end_y   = min(welt->get_groesse_y() - 1, pos.y + hbesch.get_h(rotate) + spacing);
    sint16       const  end_x   = min(welt->get_groesse_x() - 1, pos.x + hbesch.get_b(rotate) + spacing);
    for (sint16 y = start_y; y < end_y; ++y) {
        for (sint16 x = start_x; x < end_x; ++x) {
            fab_map[fab_map_w * y + x / 8] |= 1 << (x % 8);
        }
    }
}


There have been some suggestions that this parameter ought to take effect only as regards industries in the same chain. Looking at the finde_zufallsbauplatz method, there seems be a "radius" parameter, which, if I understand correctly, can be used to set where the factories are built relative to specific points.

Could this be used to make the factory spacing work in-chain only (replacing the sint16 const  spacing = welt->get_settings().get_factory_spacing(); line with something like "const spacing = 2")?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

wlindley

I find two previous threads which touched on this:

Quote from: sdog on February 24, 2011, 11:55:18 PM
...In experimental we have an excellent algorithm creating and sizing towns in a very realistically looking way, based on the topology. Viz. settlements are attracted by water and preferably build clusters. I wonder if it is feasible to use this method also for industry placement...

Quote from: ras52 on July 17, 2011, 07:38:27 AM
...I cannot see any real-life justification for preventing factories from being arbitrary close.  Walk down a high street, and you may well find a pub next door to a bakery, a grocers or even another pub; go to an industrial estate, and you may find a brewery next to a textile mill; visit a rural dale somewhere and you may find sheep farm after sheep farm, all next to each other...

What would happen if the minimum distance were not enforced for shops (industries that only receive goods)... would that result in more of them placed better within cities?

jamespetts

I agree with you in principle as to industry spacing. The idea of this thread is just to get some assistance in exploring the code and examining feasibility and how it would actually work.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

isidoro

I would say that this minimum distance should apply in a per industry type fashion.  For instance, there can't be two butcher's less that 200 m away.  And, if for game reasons, it is also wanted, the producer for that butcher's have to be more than 500 m away.

On the other hand, some other industries (natural resources) tend to cluster.  For instance, mines.  In those cases, a minimum distance should be enforced but also an affinity to be near other same mines.


jamespetts

Yes, this would be very helpful. But can any of the work be done by the "radius" function in finde_zufallsbauplatz, does anyone know?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

prissi

You would then have a map per industry. Simple as this.