Author Topic: Factory Locations: Ports, Mills, Mines  (Read 21399 times)

0 Members and 1 Guest are viewing this topic.

Offline wlindley

Factory Locations: Ports, Mills, Mines
« on: September 14, 2009, 02:56:12 PM »
Currently a factory can be defined in its .dat file as having a location of land, city, or water. 

I propose adding the following, to make the maps more realistic and to fill the need for Ports.  Ports become especially important in the British pak, for example, in the late 1900s when domestic goods manufacturing should be replaced by imported goods; Ports would also be useful in a (hypothetical) American pak that begins in Colonial times when raw materials were exported and finished goods imported (by law, even).

The proposal.  Add:

  • location = shore -- This would force an industry (like a Port) to be created on water that communicates with the edge of the map. (When creating such an industry, start on water at the edge of the map and move randomly until you hit land.)
  • location = river -- Forces the industry to be built next to a river.  Early mills of all types would use this.
  • location = hill -- Forces the industry to be built at or above the map's average land height. Useful for mines.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Factory Locations: Ports, Mills, Mines
« Reply #1 on: September 14, 2009, 03:22:36 PM »
  • location = shore -- This would force an industry (like a Port) to be created on water that communicates with the edge of the map. (When creating such an industry, start on water at the edge of the map and move randomly until you hit land.)
it should be possible with climate=water

  • location = hill -- Forces the industry to be built at or above the map's average land height. Useful for mines.
similarly, it should be possible with climate=rocky (although not all the maps have rocky height)

  • location = river -- Forces the industry to be built next to a river.  Early mills of all types would use this.
this would be VERY useful!



VS -- how are they going, the efforts to create a new climate system not based on height? :::)

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1995
  • Total likes: 3
  • Helpful: 30
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Factory Locations: Ports, Mills, Mines
« Reply #2 on: September 14, 2009, 03:30:53 PM »
I like the idea also, but the shore option was discussed and it has a problem: rotations! You'll never know which part will be over the water on random rotation.
Nice idea for hill and river, but maybe river has same problem described above ...

Offline The Hood

Re: Factory Locations: Ports, Mills, Mines
« Reply #3 on: September 14, 2009, 05:34:56 PM »
I support this.  I know the shore idea could be tricky to code, but is there any mileage in doing something like in the screenshot below?  How hard is it to require a "straight" edge of shore for, say, 2 tiles (as in the screenshot), and then build on top with artificial slopes (all done by the factory builder AI)?  Ideally, the AI would know which edge was closest to the shore so if it was a port, for example, cranes could be built on that side.

I'd also love the location=shore ability for attractions as well...

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4849
  • Total likes: 25
  • Helpful: 63
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Factory Locations: Ports, Mills, Mines
« Reply #4 on: September 14, 2009, 06:15:29 PM »
Shore is in some form already possible with location=water...

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Offline The Hood

Re: Factory Locations: Ports, Mills, Mines
« Reply #5 on: September 14, 2009, 06:31:10 PM »
Doesn't location=water make it actually in the water, like a deep-sea oil rig?

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4849
  • Total likes: 25
  • Helpful: 63
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Factory Locations: Ports, Mills, Mines
« Reply #6 on: September 14, 2009, 07:36:24 PM »
Hm... then I may have mistaken it for climate(s?)=water. Sorry. But I know something like that does already exist.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Factory Locations: Ports, Mills, Mines
« Reply #7 on: September 14, 2009, 09:13:39 PM »
VS -- how are they going, the efforts to create a new climate system not based on height? :::)

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 16086
  • Total likes: 438
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Factory Locations: Ports, Mills, Mines
« Reply #8 on: September 14, 2009, 10:04:03 PM »
This seems like a very sensible idea. It'd be excellent, as The Hood said, to have it for attractions, too: piers and beaches would be wonderful!
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.

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4849
  • Total likes: 25
  • Helpful: 63
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Factory Locations: Ports, Mills, Mines
« Reply #9 on: September 15, 2009, 01:32:10 PM »
VS -- how are they going, the efforts to create a new climate system not based on height? :::)

Not going at all. I have a finished, deterministic recipe for one part of that, the humidity, which is (imho) the hardest part wrt. planning and testing. Making this into actual Simutrans code would require some serious number crunching with Fourier transform... I am not really sure how hard that would be. In the concept demo I used plain convolution which is of course easier to do... but infinitely slower.

Even once that is in place... I can't remember outright, but the other parts were also temperature, a GUI to control these parameters, and finally combining these two into new climates, which requires changes to drawing terrain.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Factory Locations: Ports, Mills, Mines
« Reply #10 on: September 15, 2009, 01:47:25 PM »
well, that's a pity there is no progress, i was really *looking forward* to this feature. it' would be awesome!
is there any chance to simplify the model, at the cost of losing some precision?

Offline wlindley

Re: Factory Locations: Ports, Mills, Mines
« Reply #11 on: September 15, 2009, 01:55:58 PM »
What, no Simutrans weather forecasts? But seriously...

For river and shore --

I have looked at the factory builder code. The comments and symbols are quite a mix of German and English -- fortunately I can more-or-less read German, and I used to write C for a living in the 90s, so I could take a stab at this.

There is code for placing factories inside cities (and more specifically, right next to a road) but I don't see anything that would do the "shore" part.  I do imagine that "place a factory next to a river" wouldn't be too different from "place next to a street" although you'd probably pick a random point on the map and then search horizontally/vertically until you find a river, and then apply the "place along" bit.  For placing a factory with "shore" I imagine you'd pick a random ocean point on the edge of the map and then search perpendicular to the map edge for landfall, and then apply the "place along" bit.  

Does that sound logical?  

Offline Combuijs

  • Web Team
  • Devotee
  • *
  • Posts: 1387
  • Total likes: 22
  • Helpful: 53
  • Maintainer of maps.simutrans.com
    • Combuijs
  • Languages: EN, NL
Re: Factory Locations: Ports, Mills, Mines
« Reply #12 on: September 15, 2009, 02:07:10 PM »
It sounds quite logical, apart from the last one:

Quote
For placing a factory with "shore" I imagine you'd pick a random ocean point on the edge of the map and then search perpendicular to the map edge for landfall, and then apply the "place along" bit.

There are also a lot of "lakes" on the map, e.g. a collection of water tiles fully surrounded by land. They won't be found in your algorithm. But you could probably take the same algorithm for rivers, and search for water instead of river.

In both cases you might want an upper limit of tiles to be searched and of course you should not look only horizontal/vertical but probably the area in a region around the random point. I'm sure there is code for that when  factories must be placed in a certain climate (=height). As a consequence finding a suitable tile might fail.
Bob Marley: No woman, no cry

Programmer: No user, no bugs



Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4274
  • Total likes: 195
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Factory Locations: Ports, Mills, Mines
« Reply #13 on: September 15, 2009, 02:09:38 PM »
yes :)

There is also 'location=water' for attractions, check the light house in pak64. The corresponding check looks for tiles that are sloped and on water level (i.e. slopes on the shore). A place is accepted if all tiles are sloped shore tiles (which is fine for 1x1 buildings like the lighthouse).

The 'location=water' for factories works different, it is used for oil rigs for example.
Parsley, sage, rosemary, and maggikraut.

Offline wlindley

Re: Factory Locations: Ports, Mills, Mines
« Reply #14 on: September 15, 2009, 02:17:08 PM »
Yes, I was thinking of "Ports" which would necessarily be on water near the edge of the map.   A nuclear reactor, though, would often be on a lake as well, for cooling.  Maybe we need two kinds of "shore."

Offline z9999

Re: Factory Locations: Ports, Mills, Mines
« Reply #15 on: September 15, 2009, 03:53:47 PM »
There is code for placing factories inside cities (and more specifically, right next to a road)

Yes, but it doesn't consider direction of building image, even if it has 4 direction images.
That is not a big problem if a building is square like as 1x1 or 2x2.
But if may have a problem if a building isn't square like as 1x2.

Offline dannyman

Re: Factory Locations: Ports, Mills, Mines
« Reply #16 on: September 15, 2009, 08:04:02 PM »
NOTE: you can go to the trouble of finding water on the edge of the map, put a dock along the "ocean" and then later expand the map and find the "ocean" was just a large lake . . .

-d

Offline The Hood

Re: Factory Locations: Ports, Mills, Mines
« Reply #17 on: September 16, 2009, 07:47:14 AM »
I think if people decide to extend the map manually they can learn to live with the consequences ;)

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Factory Locations: Ports, Mills, Mines
« Reply #18 on: September 16, 2009, 07:55:36 AM »
find the "ocean" was just a large lake . . .

this is a true gem of philosophy! ;)

Offline whoami

Re: Factory Locations: Ports, Mills, Mines
« Reply #19 on: September 16, 2009, 07:12:49 PM »
one part of that, the humidity, which is (imho) the hardest part wrt. (...) the other parts were also temperature, a GUI to control these parameters, and finally combining these two into new climates, which requires changes to drawing terrain.
When I read the thread regarding this, I already wanted to ask whether (or why) you (plural) want to make ST a climate simulator.
It might be easier to first prepare the actual new implementation of climates, and later introduce additional methods of simulating their natural distribution on the map.

For this extension request: The factory builder already has problems finding proper locations for all the factories in a chain, leading to incomplete (and therefore dysfunctional) chains, a problem still waiting for a solution. For attractions and foundation of cities, it would be easier to deal with the location preference.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • Total likes: 7
  • Helpful: 91
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Factory Locations: Ports, Mills, Mines
« Reply #20 on: September 17, 2009, 10:10:57 AM »
  • location = river -- Forces the industry to be built next to a river.  Early mills of all types would use this.

Quote from: Timothy
Often features in Simutrans come about because of people drawing things, [...]the coding is more likely to be done for them.



 ;D ;D ;D

well, thank you vilvoh for the quotation ;)

Offline vilvoh

  • One of the good guys
  • Administrator (Inactive)
  • *
  • Posts: 4504
  • Total likes: 2
  • Helpful: 14
  • I'm the constructor, the architect
    • Escala real
Re: Factory Locations: Ports, Mills, Mines
« Reply #21 on: September 17, 2009, 10:29:30 AM »
Then, I must support it.. ;D

Escala Real...a blog about Simutrans in Spanish...

Offline wlindley

Re: Factory Locations: Ports, Mills, Mines
« Reply #22 on: January 05, 2014, 12:02:36 AM »
This might be simpler than we thought.  Define a new Location= parameter, "water" which maps to the enumerated constant Fluss (are we continuing to code in German?):

Code: [Select]
diff --git a/besch/fabrik_besch.h b/besch/fabrik_besch.h
index a672728..f3d59f6 100644
--- a/besch/fabrik_besch.h
+++ b/besch/fabrik_besch.h
@@ -210,7 +210,7 @@ class fabrik_besch_t : public obj_besch_t {
        friend class factory_reader_t;
 
 public:
-       enum site_t { Land, Wasser, Stadt };
+       enum site_t { Land, Wasser, Stadt, Fluss };
 
 private:
        site_t platzierung; //"placement" (Babelfish)
diff --git a/besch/writer/factory_writer.cc b/besch/writer/factory_writer.cc
index ba84a67..5de002c 100644
--- a/besch/writer/factory_writer.cc
+++ b/besch/writer/factory_writer.cc
@@ -158,6 +158,7 @@ void factory_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& obj
                !STRICMP(placing, "land")  ? fabrik_besch_t::Land   :
                !STRICMP(placing, "water") ? fabrik_besch_t::Wasser :
                !STRICMP(placing, "city")  ? fabrik_besch_t::Stadt  :
+               !STRICMP(placing, "river")  ? fabrik_besch_t::Fluss  :
                fabrik_besch_t::Land;
        uint16 const produktivitaet = obj.get_int("productivity",        10);
        uint16 const bereich        = obj.get_int("range",               10);

Then in simwerkz.cc, in the definition of wkz_build_factory_t::work we have …
Code: [Select]
        if(fab->get_platzierung()==fabrik_besch_t::Wasser)
        {
                // at sea                 

        }
        else
        {
                // and on solid ground                                                                         
                hat_platz = welt->square_is_free( k.get_2d(), fab->get_haus()->get_b(rotation), fab->get_haus()->get_h(rotation), NULL, cl );

                if(!hat_platz  &&  size.y!=size.x  &&  fab->get_haus()->get_all_layouts()>1  &&  (default_param==NULL  ||  default_param[1]=='#'))

        }

        if(hat_platz) {
                // eventually adjust production 

Now, just above the final if(hat_platz) -- "has location" -- add a new code stanza that loops over the prospective factory's borders, looking at each tile that sits outside and immediately adjacent to the factory site, and checks that at least one of those squares is a River square; if none are, clear hat_platz. That's all that's required.

One catch might be that fabrikbauer_t::increase_industry_density has a "retrys" loop that counts to twenty, before giving up on building a factory.  If rivers are fairly scarce, that probably will result in no factories being built, although it's worth testing.  The constant 20 could be changed to "40 for river factories, 20 for all other."

Also, we might want the river square test to be true only for sufficiently large rivers: mills weren't built next to creeks, but at least moderately sized streams.

Can someone help me write the river-check loop?

A

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 16086
  • Total likes: 438
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Factory Locations: Ports, Mills, Mines
« Reply #23 on: January 05, 2014, 12:06:49 AM »
This is very interesting. Industry requiring rivers would be a worthwhile development. I do worry somewhat that this suggested version of the code might make map generation take a long time, especially on larger maps, however, although it would need testing.

Water mills (and, for that matter, windmills, which require no new code) would be a most welcome addition to paksets that go to early times, such as Pak128.Britain, but even some modern industries (hydro-electric power stations were mentioned back in 2009) require a nearby river.
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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4895
  • Total likes: 215
  • Helpful: 108
  • Languages: EN, NO
Re: Factory Locations: Ports, Mills, Mines
« Reply #24 on: January 05, 2014, 09:14:08 AM »
Some of these industries, like power stations (or strictly speaking their dams, the power station itself can be far away) and some (most?) mills, aren't really built next to a river, but on a river slope. They furthermore block that river for traffic.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 16086
  • Total likes: 438
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Factory Locations: Ports, Mills, Mines
« Reply #25 on: January 05, 2014, 12:20:17 PM »
Ahh, yes, I suppose that that must be right; different, I suppose, to a factory such as a tannery that would need to be beside a river for a constant supply of water.
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.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4895
  • Total likes: 215
  • Helpful: 108
  • Languages: EN, NO
Re: Factory Locations: Ports, Mills, Mines
« Reply #26 on: January 05, 2014, 12:34:09 PM »
Things like tanneries should also work at lakes (fresh water), but not the sea (salt water)?

Offline wlindley

Re: Factory Locations: Ports, Mills, Mines
« Reply #27 on: January 05, 2014, 03:07:53 PM »
Perhaps the loop for creation, then, instead of "try 20 random tiles within the desired location radius" would be "start in the desired location, and proceed alternately north/south/east/west for some steps to see whether a tile of the required constraint exists, and if so build the factory there." 

The constraint being one of, say: sits next to river slope; sits atop river slope (e.g., dams, mills); sits next to lake or medium or larger river, not ocean (i.e., tanneries); within 2 tiles of major river, lake, or ocean (steel mills); is adjacent to several heavily forested tiles (sawmill)...

Would that work well?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8830
  • Total likes: 324
  • Helpful: 229
  • Languages: De,EN,JP
Re: Factory Locations: Ports, Mills, Mines
« Reply #28 on: January 05, 2014, 09:05:36 PM »
It is: Try for 50 random location an area of 25x25 tiles for a match.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4274
  • Total likes: 195
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Factory Locations: Ports, Mills, Mines
« Reply #29 on: January 06, 2014, 07:39:13 PM »
here is a quick patch. it adds the following options to the location parameter:

river: one tile of factory adjacent to river tile
shore: one tile of factory on a sloped shore tile
forest: more than X trees on the tiles covered by the factory, X=area of factory

Windows executables for patched version of simutrans and makeobj:
http://simutrans-germany.com/files/upload/sim-win-7003-factory-placement.zip

Edit: More on the implementation: No check whether the shore tile is connected to an ocean. No check for major rivers or lakes. Building dams is pretty tough code-wise.

If the factory site finder gives up looking for places with the right climates it still considers the location constraint. That is, a factory with location=river will only placed on rivers or never be built (if the site finder does not find a suitable spot). This can be changed ofc.
« Last Edit: January 06, 2014, 07:45:13 PM by Dwachs »
Parsley, sage, rosemary, and maggikraut.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 16086
  • Total likes: 438
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Factory Locations: Ports, Mills, Mines
« Reply #30 on: January 06, 2014, 07:49:39 PM »
This is a splendid thing to have done so quickly - can really add depth to the game. One practical issue that has occurred to me is that network games often have no trees to reduce transfer times, which might make the forest setting undesirable in some cases. But, in any event, a splendid addition.
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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8830
  • Total likes: 324
  • Helpful: 229
  • Languages: De,EN,JP
Re: Factory Locations: Ports, Mills, Mines
« Reply #31 on: January 07, 2014, 09:52:06 PM »
People also play without rivers. At a certain point probably these constraint needs to be lifted (or one has to live with incomplete chains).

Offline greenling

  • Lounger
  • *
  • Posts: 1728
  • Total likes: 2
  • Helpful: 15
  • Simutransarchology it my hobby!
  • Languages: DE,EN
Re: Factory Locations: Ports, Mills, Mines
« Reply #32 on: January 12, 2014, 05:54:10 PM »
Hello All
Those Idea it´s not good the bringing players in problems.
Opening hours 20:00 - 23:00
(In Night from friday on saturday and saturday on sunday it possibly that i be keep longer in Forum.)
I am The Assistant from Pakfilearcheologist!
Working on a big Problem!

Online Leartin

Re: Factory Locations: Ports, Mills, Mines
« Reply #33 on: January 18, 2014, 11:47:40 AM »
shore: one tile of factory on a sloped shore tile

As in, it is buildt on land as usual, but one tile is a sloped shore?
Would it be possible to build it on water with one tile (or one side) on the shore, ideally with a proper alignment (so the artist knows on which side of his building the shore will be)?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8830
  • Total likes: 324
  • Helpful: 229
  • Languages: De,EN,JP
Re: Factory Locations: Ports, Mills, Mines
« Reply #34 on: January 18, 2014, 09:10:29 PM »
THe only difference from shore and climate=water is that with the latter all tiles must be on a slope. If the building is 2x1, this will enforce that both are on the slope.