News:

SimuTranslator
Make Simutrans speak your language.

Factory Locations: Ports, Mills, Mines

Started by wlindley, September 14, 2009, 02:56:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wlindley

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.

Fabio

Quote from: wlindley on September 14, 2009, 02:56:12 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

Quote from: wlindley on September 14, 2009, 02:56:12 PM

  • 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)

Quote from: wlindley on September 14, 2009, 02:56:12 PM

  • 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? :::)

Zeno

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 ...

The Hood

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...

VS

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!

The Hood

Doesn't location=water make it actually in the water, like a deep-sea oil rig?

VS

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!

Fabio

Quote from: fabio on September 14, 2009, 03:22:36 PM
VS -- how are they going, the efforts to create a new climate system not based on height? :::)

jamespetts

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.

VS

Quote from: fabio on September 14, 2009, 03:22:36 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!

Fabio

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?

wlindley

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?  

Combuijs

It sounds quite logical, apart from the last one:

QuoteFor 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



Dwachs

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.

wlindley

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."

z9999

Quote from: wlindley on September 15, 2009, 01:55:58 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.

dannyman

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

The Hood

I think if people decide to extend the map manually they can learn to live with the consequences ;)

Fabio


whoami

Quote from: VS on September 15, 2009, 01:32:10 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.

Fabio

Quote from: wlindley on September 14, 2009, 02:56:12 PM

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

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

Quote from: Diegote on September 17, 2009, 01:05:59 AM


;D ;D ;D

well, thank you vilvoh for the quotation ;)

vilvoh


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

wlindley

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?):


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 ...
        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

jamespetts

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.

Ters

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.

jamespetts

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.

Ters

Things like tanneries should also work at lakes (fresh water), but not the sea (salt water)?

wlindley

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?

prissi

It is: Try for 50 random location an area of 25x25 tiles for a match.

Dwachs

#29
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.
Parsley, sage, rosemary, and maggikraut.

jamespetts

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.

prissi

People also play without rivers. At a certain point probably these constraint needs to be lifted (or one has to live with incomplete chains).

greenling

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!

Leartin

Quote from: Dwachs on January 06, 2014, 07:39:13 PM
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)?

prissi

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.