The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: Fabio on January 19, 2009, 06:49:21 AM

Title: Rivers development
Post by: Fabio on January 19, 2009, 06:49:21 AM
I want to revive this issue, now that there are many patchers. i would look at it myself, if i only had a little knowledge about C/C++.

I believe rivers would add some more realism and also some interesting challamges for the gameplay.

Rivers could be canals with a lower weight allowed. They could be built at the beginning of the game, BEFORE cities. Once the player sets a number of rivers in the new world dialogue, the program could randomly select n pairs of tiles, one on the shore and one on a higher level of ground. A waybuilder (maybe recycling the one for intercity roads) could try to connect the two tiles, favouring more bends. From the shore to the source, the path should be forced to go horizontal OR to climb, never to go down.
Additionally, for every tile on the shoreline, there could be more (2 op to 4) tiles on higher grounds and the river could split in different affluents at random points of its path. the river would be owned by the public player and could be upgraded to channel by the players.

Gameplay impact:
- a challange for the player to cross a new kind of natural obstacle.
- an opportunity, at the beginning of the game, to exploit natural routes using low weight and low speed barges.
Title: Re: Rivers development
Post by: Dwachs on January 19, 2009, 07:22:34 AM
One can even include some rain estimations to let rivers grow from the mountains (see the 'equatorial wind' topic).

One important thing that has to be dealt with:
What happens if the user changes slopes near river tiles? are such changes allowed at all?
Title: Re: Rivers development
Post by: Fabio on January 19, 2009, 07:59:31 AM
there have been complex discussions on the two previous forums. But all the time rivers have been deemed as too complex and dumped.

my favourite choice, now, would be a static way object (waytype=water), which would imply easier coding and known results.

the rain estimations could influence its source tile and its path. maybe rivers could be forbidden at all in deserts and more likely in such climates as tropical ones. Also the size (graphical, but which could have different max weight and max speed) could vary with the path and the climate. but i believe this should be further tweaks.

IMHO the priority would be a waybuilder (which at the beginning could use normal canals (waytype=water).
Title: Re: Rivers development
Post by: vilvoh on January 19, 2009, 08:09:57 AM
Well, as far as I know, the current road system sets a max weight and speed for each road type so why not implementing the same system to rivers?
Title: Re: Rivers development
Post by: Fabio on January 19, 2009, 08:20:46 AM
I think the weight are now for all waytypes. if not, canals (and rivers) would definitely need it (e.g. to prevent/discourage big oil tankers to go through rivers/canals.

Also, rivers would be a help for the player at the start of the game, as they could use them for small barges. But later in the game, they would probably need to upgrade part of the river to a wider canal size, to allow bigger barges and higher speeds.
Title: Re: Rivers development
Post by: The Hood on January 19, 2009, 09:17:33 AM
I totally support this idea.  I have long hoped for a system where rivers can be used like very basic canals which were built on map-generation.  If possible I would also ask:
- That rivers were quite curvy, encouraging people to build short-cut canals early in the game
- That cities were generated on rivers preferentially at the start of the game.
- That rivers can be upgraded to higher capacity canals by the player.

Hopefully this isn't too hard!
Title: Re: Rivers development
Post by: AP on January 19, 2009, 10:37:00 AM
Several things come to mind:

Rivers should be able to have a "source" on-map. That is, just start from nothing at a high elevation. No requirement to run across the entire map or something.

Elevation needs careful handling. I think rivers should be lower than the rest of the map (unlike canals say) by 1 tile. This means, realistically, there is no need for little hump-back railway bridges all over the place (slowing my trains down!) - they need to be able to be crossed on the level.

Is it possible to code them so that the max speed when moving against the flow is slower than the max speed moving with the flow? I mean, if the river has a source, can it know which way down is?

You'd need a "lake" feature in case the map generates a river flowing into an endorheic basin (http://en.wikipedia.org/wiki/Endorheic_basin) - a low area with no  possible outflow (e.g the Caspian Sea is such a lake).

It would be nice if rivers could be made to branch off, if confluences occured naturally after every n tiles (give or take), so on a large map you'd have a river with several tributaries. A crude natural canal network.

I assume I'm not the only one who would start wanting wherries and such in-game?
(http://www.wherryalbion.com/USERIMAGES/albion-on-barton-small.jpg)
Title: Re: Rivers development
Post by: The Hood on January 19, 2009, 11:04:00 AM
wherries are planned for PakBritain, but not in the next release!
Title: Re: Rivers development
Post by: emaxectranspoorte on January 19, 2009, 02:20:18 PM
More things need looking for, in my humble opinion: :)

1. The differences between the colours changes between sea and rivers (seas are normally green of colour, rivers are blue)
2. Smaller rivers may be called streams (with smaller weight capacity for ships).
3. Speaking of smaller to medium wheight capacity, in bigger and/or wider and/or deeper river canals, should not matter that much for ships with a smaller to medium wheight capacity. (just like bigger ships don't really matter that much with the sea in terms of wheight (with or without carrying a load (passangers and/or  mail and/or goods): for example: the Batillus Supertanker Add-On for sea usage only).
:-\

EDIT: I have forgotten, sorry, since there's going to be differentiation in between different types of rivers (like mountainous and plains, for example, (there may be more, but I can't think of any more at this time), we could even include more new industry chains, and also improvements to older industry chains (for river plains), as well (for example: irrigated (one or two tiles near a river) grain farms produce more goods).

EDIT2:  ??? In tropical climates there should be no rivers? :o I know that in the deserts maybe there shoudn't be any rivers, and definitely no streams. But not in tropical climates? :o I mean, there are rivers in, for example, South America, right? :-\

EDIT3: Fabio and AP, do you also mean deltas near the sea, not just river tributaries? :-\



Title: Re: Rivers development
Post by: jamespetts on January 19, 2009, 04:49:22 PM
Rivers would indeed be excellent from a gameplay point of view, and would make bridges far more useful. They would really make a difference.
Title: Re: Rivers development
Post by: emaxectranspoorte on January 19, 2009, 04:57:06 PM
Are you reffering to diversifying bridge differences in between sea and/or rivers, if you don't mind me asking? :-\

EDIT: You are quite right, James. :)
Title: Re: Rivers development
Post by: vilvoh on January 19, 2009, 05:00:51 PM
Quote from: emaxectranspoorte on January 19, 2009, 02:20:18 PM
we could even include more new industry chains, and also improvements to older industry chains, as well (for example: irrigated (one or two tiles near a river) grain farms produce more goods).

That's very interesting because there're a lot of old industries from 1900 and earlier that depend on water power (mills), and transporting goods by rivers was a very common mean in the past (wood, stone, sand, salt, etc..)

Quote from: emaxectranspoorte on January 19, 2009, 02:20:18 PM
EDIT2:  ??? In tropical climates there should be no rivers? :o I know that in the deserts maybe there shoudn't be any rivers, and definitely no streams. But not in tropical climates? :o I mean, there are rivers in, for example, South America, right? :-\

I guess you don't know Amazonas (the second largest river on earth) and Orinoco....  ::)....The Nilo is in a tropical climate too (I would say desert climate)
So the veredict is: yes, there must be rivers in tropical climates and probably they will be the largest of all climates.
Title: Re: Rivers development
Post by: emaxectranspoorte on January 19, 2009, 05:15:54 PM
Thank you for considering what I thought about, vilvoh. :)

Quote from: vilvoh on January 19, 2009, 05:00:51 PM
That's very interesting because there're a lot of old industries from 1900 and earlier that depend on water power (mills), and transporting goods by rivers was a very common mean in the past (wood, stone, sand, salt, etc..)
Yes, that's correct. I was even thinking of something similar, as well (maybe like some ... kind of older looking assembly facility near the depot, for example, for constructing older type ships from the 1800 to the 1900 era), to carry those types of goods, and even passengers and/or mail.
Quote from: vilvoh on January 19, 2009, 05:00:51 PM
The Nilo is in a tropical climate too (I would say desert climate)
That's what I based my idea about the irrigation of some industries (for example, mills (of any type)). :)
Title: Re: Rivers development
Post by: Roads on January 19, 2009, 05:53:40 PM
Whenever I create a new game I go into public service mode and use the terrain tool to make something akin to rivers.  That's how much I like them.  No doubt there are many problems creating them though.  Even advanced as SC4 is, the rivers are not very realistic.  From what I've seen and understand about heightmaps, water has to be no higher than altitude zero.  That situation created some very nice looking cliffs in SC4 but unfortunately does not allow for realistic water wheels since there is no such thing as "fall."

I suggested in the "equatorial wind" thread that perhaps rivers could be painted on like houses, etc.  VS did not reply to that suggestion so I don't know if he thought it was too stupid or is still considering it.  I do think it is possible that some of these terrific artists could paint some river tiles - reference how great the fish ponds look.  Maybe we could even have some tiles with water flowing and water falls.  Wouldn't it be possible to do them a similar way as trucks moving or people walking?

At any rate if something like this is done or no, it would still be nice to have some water transportation that is not so expensive early on.  I've found I have to have a pretty big operation to afford anything when it comes to water transportation.
Title: Re: Rivers development
Post by: emaxectranspoorte on January 19, 2009, 06:18:14 PM
Quote from: Roads on January 19, 2009, 05:53:40 PM
I do think it is possible that some of these terrific artists could paint some river tiles - reference how great the fish ponds look.  Maybe we could even have some tiles with water flowing and water falls. At any rate if something like this is done or no, it would still be nice to have some water transportation that is not so expensive early on. 
Yes, that's correct. :) Exactly what I was thinking about, as well. We can even have a graphical moving water based objects, to make it even better, IMHO. And add new industries at the bottom of the river flow (say near a city and/or near sea and/or city level), using that river as an irrigation resource (for irrigating farms, adding, maybe, a destination for the bottling industries, etc...) and somewhere during the rivers running we could add (and/or also a source for the bottling industries) a resting place (for example a national park), only with boat transportation to make it more peacefull and somewhere for simuthanians to enjoy a wonderfull time with their families. :)
Quote from: Roads on January 19, 2009, 05:53:40 PM
Wouldn't it be possible to do them a similar way as trucks moving or people walking?
??? Oh ... you mean the river flowing like trucks moving or people walking, right? :-\
Quote from: Roads on January 19, 2009, 05:53:40 PM
I've found I have to have a pretty big operation to afford anything when it comes to water transportation.
Yes, I have found out about that, as well. :) :o
Quote from: AP on January 19, 2009, 10:37:00 AM
I assume I'm not the only one who would start wanting wherries and such in-game?
Yes, you're right AP, you aren't the only one :) Maybe gondolas would be another one, IMHO. :-\
Title: Re: Rivers development
Post by: VS on January 19, 2009, 07:45:37 PM
Roads, sorry, I probably overlooked it or did not feel like going on another tangent. The whole weather campaign has two parts: 1) add precipitation as a parameter for every tile and 2) new climates based on that. That said, it would make sense to build upon this further and choose river starting points based on this data. But that would be even part #3... and rather detached from what is discussed here. There is a difference between adding rivers and such into game, and choosing where they start.




My 2c on rivers...

I may be wrong, but there should be more classes of river, according to size. Small streams, rivers, large navigable rivers. It somehow seems wrong to have a river starting at some point and staying the same all the way towards ocean. The last kind should allow for seamless connecting of tiles in the same direction to the side, so that at the last class, river could grow in width to more than one tile.

Cities and industries near rivers would be great, too.
Title: Re: Rivers development
Post by: Roads on January 19, 2009, 08:00:33 PM
No need to apologize VS.  I realized at the time it was going off topic and also that you needed to maintain focus on the subject to ever get anything accomplished.

At some point I'm still planning to get in on the programming side of things.  Until then I'll just be happy with whatever is done.

I agree with you totally about rivers.  It is unrealistic and we would likely soon become dissatisfied if the rivers were not part of the total picture and that of course includes streams.  My feeling is that with the graphic engine we have now it might not be possible to incorporate rivers in any way that would not have to be redone later on.  But, who knows, maybe someone will come up with a clever plan...
Title: Re: Rivers development
Post by: AP on January 19, 2009, 08:09:31 PM
Quote from: emaxectranspoorte on January 19, 2009, 02:20:18 PM
EDIT3: Fabio and AP, do you also mean deltas near the sea, not just river tributaries? :-\
Deltas and Rias (flooded river valleys) are relatively rare geographic features, actually. Most rivers just have an estuary (ie get gradually wider and more saline as they meet the sea).

So I specifically meant tributaries. The further from the sea, the more branches a river should have to successfully drain its watershed.

Title: Re: Rivers development
Post by: The Hood on January 20, 2009, 09:25:50 AM
Practical idea - to make things easiest to implement to start with, could we go with something like the following logic on map creation - then once we have that working in the game to start thinking of other nice things to add in?

1 - generate land with heights / climates as at present
2 - before adding cities, industries, roads etc, add rivers:
     a - pick a square on the terrain on the height 1 or 2 levels down from the highest points
     b - build a "river" waytype (which would be coded like a canal) from that point, making it head only downwards until it reaches the sea or another river.  This process would reject ways which end in depressions with no way to the sea, and would also include some randomness in direction, e.g. 80% chance of carrying on in same direction, 10% chance of turning right, 10% left (this would have to be tested and altered to make it work).
3 - build cities, industries, roads as before

If we try to make things too complicated now from the start, it will be a nightmare for anything to get done, but if we can get something simple then we can take it from there and see what happens.  Anyone who knows code know how hard my logic would be to code?
Title: Re: Rivers development
Post by: Spike on January 20, 2009, 09:37:23 AM
Quote from: The Hood on January 20, 2009, 09:25:50 AM
     b - build a "river" waytype (which would be coded like a canal) from that point, making it head only downwards until it reaches the sea or another river.  This process would reject ways which end in depressions with no way to the sea, and would also include some randomness in direction

It could also fill those depressions, creating a lake, until it "flows over" somewhere, spawning a new river from that point.

I've several times tried to implement this, but always felt too lazy to actually do it. It should work though, without big problems. What stopped me in the past was the lack of riverbed/riverside tiles, and I felt not inspired to draw like 48 new tiles just for the rivers ... nowadays the work could be shared among coders and painters, so it's not so overwhelming anymore.

Title: Re: Rivers development
Post by: The Hood on January 20, 2009, 09:53:25 AM
I would be happy to draw rivers, but at present it would be a way down my to do list as I'm concentrating on making a stand-alone PakBritain release.
Title: Re: Rivers development
Post by: Spike on January 20, 2009, 09:58:36 AM
Maybe one doesn't need so many tiles anymore nowadays. Shores and climate transitions are calculated from light maps and textures. I have no idea if those code can be employed for rivers, too, but basically it should be able to do it, since shores and riversides are very similar, and water would just be like another ground texture for a climate.
Title: Re: Rivers development
Post by: vilvoh on January 20, 2009, 09:59:52 AM
That may be easy to achieve with Blender. A couple of surfaces, with fractal, reflection and transparency to simulate depth. We can make side and center tiles in order to have lakes, not only rivers. So now we only need coders.. ;)

P.S: Wouldn't be possible to use current water tiles? at least in early stages, just for testing proposes.
Title: Re: Rivers development
Post by: The Hood on January 20, 2009, 11:00:25 AM
Why do rivers need separate graphics for shores?  Surely if they are coded as a waytype then they would just need to be drawn in a similar way to roads / canals etc.?
Title: Re: Rivers development
Post by: Roads on January 20, 2009, 11:17:37 AM
I have to agree with Hood on this.  When you created what passed for rivers in SC4, the banks of the river looked like normal sloped tiles.  Heck, even in real life the river closest to me has, for the most part no distinguishing characteristic at the bank.  Occasionally there will be a bit of sand or rocky place but that is mostly at a fjord.

It would make the bank look more realistic if the water came only part way up the sloped tile.
Title: Re: Rivers development
Post by: Fabio on January 20, 2009, 11:40:07 AM
Quote from: vilvoh on January 20, 2009, 09:59:52 AM
P.S: Wouldn't be possible to use current water tiles? at least in early stages, just for testing proposes.

honestly, i agree. Consistency is important in the way the game looks, IMHO, and having similar graphics for eas, rivers and canals is a pro. and even if they have different textures, it would be important for them to be strictly consistent.
Title: Re: Rivers development
Post by: Spike on January 20, 2009, 12:46:07 PM
Quote from: The Hood on January 20, 2009, 11:00:25 AM
Why do rivers need separate graphics for shores?

I imagined riversides less steep than the shore tiles that Simutrans uses. Technically I'd have rivers let be even with the landscape, and just make the graphics so that they look slightly depressed in comparison.

But that's just me. Painters and coders sure will create their own ideas :)
Title: Re: Rivers development
Post by: The Hood on January 20, 2009, 01:49:41 PM
Quote from: Hajo on January 20, 2009, 12:46:07 PM
I imagined riversides less steep than the shore tiles that Simutrans uses. Technically I'd have rivers let be even with the landscape, and just make the graphics so that they look slightly depressed in comparison.

That's exactly what I was thinking.  Apart from in mountains / uplands, most rivers are a similar height to the land around.  And if there is a worry about having to create hump-back bridges for roads/rails to cross rivers, isn't it already possible to have "level crossings" between river and road just like between road and rail?
Title: Re: Rivers development
Post by: Fabio on January 20, 2009, 02:00:56 PM
Quote from: Hajo on January 20, 2009, 12:46:07 PM
Technically I'd have rivers let be even with the landscape, and just make the graphics so that they look slightly depressed in comparison.
I personally support this idea.
For the rest, their behaviour could be based on canals'.
IMO, the most important thing is to make the routine to draw them well at the beginning of the game. For the rest, i's a matter of pakset.

Talking of river size, they could start small and sum their size (i would measure this in weight allowed for barges and ships, starting with a mere 2-3 tons and growing bigger). The images could be 3-4: stream (up to 10 t), small (10 to 50 t), medium (50 to 100 t), big (more than 100 t).


Quote from: The Hood on January 20, 2009, 01:49:41 PM
And if there is a worry about having to create hump-back bridges for roads/rails to cross rivers

they would be a natural obstacle for the player to deal with, so it would be very ok.


Title: Re: Rivers development
Post by: AP on January 20, 2009, 02:34:36 PM
I made a post on the adjacent thread (http://forum.simutrans.com/index.php?topic=1272.30) which has relvence here. I think the river crossings should make use of an on-the-flat type of bridge, to avoid the need to cut a channel into the terrain so the river is lower than the land around.

The bridge should be a variant on the canal lift-bridge-  which is indeed on the level. If the rivers are wider than 1 tile (possible - estuaries etc) then maybe a swing bridge design could be made.
(http://newsimg.bbc.co.uk/media/images/44236000/jpg/_44236003_bridge.jpg)
Title: Re: Rivers development
Post by: IgorEliezer on January 20, 2009, 04:42:59 PM
I can't write so much.

So, I leave here some samples of estuaries, canyons, rivers and some landscape design using infrastructures in Simutrans:

http://www.racehunter.com/cpg1419/thumbnails.php?album=1
Title: Re: Rivers development
Post by: Roads on January 20, 2009, 06:33:37 PM
That is some awesome pics!  Shows what a little imagination can do.  Thanks Igor.

When I suggested that the water only come part way up the sloped tiles I was thinking about those little depressions of 2 or 3, maybe 3 or 4, you sometimes see on the map.  If I imagine these completely filled with water, it seems it would look like just green or gray tiles adjacent to blue tiles.  Of course Hajo's idea of making those adjoining tiles appear depressed somewhat would, I think, be the best looking solution.  I was just thinking about a way to do it without the need for painting more tiles for the shore.
Title: Re: Rivers development
Post by: Magic_Gorter on January 20, 2009, 07:03:07 PM
I like those pictures too.

If it's possible to create rivers I think they should start all with the same size(=well). Everytime the river goes down one or mayby two levels the size of the river should become bigger and when growing allowing bigger ships.  This way the river will be bigger when it starts at an higher level.

An other way to get a growing river is became bigger after x tiles (e.g. x=10).
Title: Re: Rivers development
Post by: emaxectranspoorte on January 20, 2009, 07:09:49 PM
I like them too. A better realistic improvement for Simutrans rivers. :)
Title: Re: Rivers development
Post by: jamespetts on January 20, 2009, 07:12:47 PM
Quote from: IgorTekton on January 20, 2009, 04:42:59 PM
I can't write so much.

So, I leave here some samples of estuaries, canyons, rivers and some landscape design using infrastructures in Simutrans:

http://www.racehunter.com/cpg1419/thumbnails.php?album=1

Very impressive! Now, if only Simutrans could be made to do that automatically, there would be a great many very happy Simutransians :-)
Title: Re: Rivers development
Post by: emaxectranspoorte on January 20, 2009, 09:27:36 PM
Quote from: emaxectranspoorte on January 19, 2009, 06:18:14 PM
Yes, that's correct. :) Exactly what I was thinking about, as well. We can even have a graphical moving water based objects, to make it even better, IMHO. And add new industries at the bottom of the river flow (say near a city and/or near sea and/or city level), using that river as an irrigation resource (for irrigating farms, adding, maybe, a destination for the bottling industries, etc...) and somewhere during the rivers running we could add (and/or also a source for the bottling industries) a resting place (for example a national park), only with boat transportation to make it more peacefull and somewhere for simutranians to enjoy a wonderfull time with their families. :) ??? Oh ... you mean the river flowing like trucks moving or people walking, right? :-\ Yes, I have found out about that, as well. :) :o
Yes, you're right AP, you aren't the only one :) Maybe gondolas would be another one, IMHO. :-\

Looking at the magnificent and cool work of all that you veterans, here, have done, I realize we beginners, like me, have to work a long way. :)

So, in spite of this, may I come up with some not so professional ideas... : :-\

1. We can use lakes, rivers, and especially streams, as natural boundaries to reduce unnecessary population growth (selected appropriately either at the start of the game and/or by a player), besides using fences, signs and the like.
2. We can also start increasing the infrastructure of the game with more additions like water pipes (similar to the waste recycling add-ons and incineration in the game), water recycling and desalination plants to further improve and diversify the current water industry (might become very useful for desert type climates, IMHO). These sort of work, in real life, implies the cost of employment and maintenance of, the number of  people, stated before that must be taken into account (similar to like employing people to maintain and improve traffic and/or train signals (with the appropriate incentives for players) for example, IMHO).
Title: Re: Rivers development
Post by: gerw on January 21, 2009, 08:44:07 AM
Quote from: jamespetts on January 20, 2009, 07:12:47 PM
Very impressive! Now, if only Simutrans could be made to do that automatically, there would be a great many very happy Simutransians :-)
I think at least for random maps this is possible. You can calculate the gradient at every point and the 'route' of the river can be estimated by an ODE.
Title: Re: Rivers development
Post by: jamespetts on January 21, 2009, 09:16:36 AM
Quote from: gerw on January 21, 2009, 08:44:07 AM
I think at least for random maps this is possible. You can calculate the gradient at every point and the 'route' of the river can be estimated by an ODE.

Ahh, I'd love to see that implemented.
Title: Re: Rivers development
Post by: VS on January 21, 2009, 11:57:01 AM
Gradient is not so easy, as I already found out during work on the rain. Easy, yes, but easy and fast? In the end I settled for gradient module in a given direction, which is easy. Calculating gradient that takes into account all surrounding terrain of any shape is far slower.

Remember that Simutrans terrain is heavily quantized in z-axis. That is the first and foremost obstacle, a kind of data that yields very little about tiles more than one index apart. Try as you might, any gradient will end in zero for most of the space, except for small "bursts" around the edges. Thus I had to smooth terrain height data before finding the gradient itself. And given the usual distances, it is a HUGE gaussian that I had to use - 30x30.

Of course you could laugh at gradient-only operators and go for something that does the smoothing for you, too, in one go, but the amount of calculations will not go down.

What is the notion of gradient here, anyway? Maybe a real gradient is not needed; could direction "to next tile downwards" be enough? Then the task is just sorting. Or maybe which neighbouring tiles are lower; then you simply store that information as 8 bits and choose at random. If this data was used only for rivers, you could simply say that the river's inertial force takes it roughly in the same direction and thus it would overcome areas where this pseudo-gradient is none. Maybe. Such method might easily degrade to prominently changing river's direction only on slopes, though...
Title: Re: Rivers development
Post by: Dwachs on January 21, 2009, 12:15:00 PM
I think 'gradient' here refers to the fact, that the surface is determined by a smooth(?) function, which is then made discrete. Thus it could be possible to compute the gradient of the smooth surface in the center of a tile. This gradient can then be made discrete again, since it only needs to point at the neighboring tile, which is lower, and which will be the next tile for the river.

See simtools.cc for the functions using perlin noise to generate the landscape.

Computational cost is another issue then.

Edit: I see your point. My remarks are valid only for the map generation phase, where the map is not influenced by player actions yet. For the creation of rivers after some time of play, your considerations come into play.
Title: Re: Rivers development
Post by: Spike on January 21, 2009, 12:45:18 PM
Quote from: Dwachs on January 21, 2009, 12:15:00 PM
Edit: I see your point. My remarks are valid only for the map generation phase, where the map is not influenced by player actions yet. For the creation of rivers after some time of play, your considerations come into play.

Rivers must "fix" the landscape height like buildings do, otherwise we face some very tricky coding questions.
Title: Re: Rivers development
Post by: VS on January 21, 2009, 12:57:42 PM
Dwachs: True... but what about heightmaps?
Title: Re: Rivers development
Post by: Dwachs on January 21, 2009, 01:55:21 PM
@VS: then your smoothing approach is needed.

@hajo: I meant, the information from the map-generation process became invalid after playing some time on a map, that is, if the player will manually insert a river.
Title: Re: Rivers development
Post by: Roads on January 21, 2009, 03:57:37 PM
One approach could be what Dwachs hinted at.  Present the player with pre-made maps like you do now but give him some additional tools to add lakes, streams and rivers.  It seems to me all you would need are the terrain tools you have now and then some shore tiles and water tiles.

After all, this is almost exactly what SC4 does.

It probably would not allow for the rivers to look like they are flowing or have waterfalls but it certainly should solve to problem of determining a direction and width that looks realistic.  Also it would provide a basis for further development and ideas. 
Title: Re: Rivers development
Post by: Spike on January 22, 2009, 10:21:40 AM
Quote from: Dwachs on January 21, 2009, 01:55:21 PM
@hajo: I meant, the information from the map-generation process became invalid after playing some time on a map, that is, if the player will manually insert a river.

I think it's good enough if there are rivers initially. It doesn't need to be a function that can be triggered any time.
Title: Re: Rivers development
Post by: VS on January 22, 2009, 10:32:45 AM
There is now a feature-complete editor mode, accessible from public player. I guess it might be needed then...
Title: Re: Rivers development
Post by: gerw on January 23, 2009, 07:37:37 PM
Rivers are coming ;)

[attachment deleted by admin]
Title: Re: Rivers development
Post by: jamespetts on January 23, 2009, 11:47:04 PM
Quote from: gerw on January 23, 2009, 07:37:37 PM
Rivers are coming ;)

This looks very promising!
Title: Re: Rivers development
Post by: emaxectranspoorte on January 24, 2009, 01:16:53 AM
It really looks like a good start to improving the rivers issue... :) IMHO.
Title: Re: Rivers development
Post by: The Hood on January 24, 2009, 10:26:49 AM
Quote from: gerw on January 23, 2009, 07:37:37 PM
Rivers are coming ;)

Was this generated at the start of the map?  If so this is an exciting development...
Title: Re: Rivers development
Post by: gerw on January 24, 2009, 07:57:47 PM
Quote from: The Hood on January 24, 2009, 10:26:49 AM
Was this generated at the start of the map?  If so this is an exciting development...
Yes, it was. But I fixed (hardcoded) the starting point and the end point. Next step are alternating starting / end points.
Title: Re: Rivers development
Post by: jamespetts on January 24, 2009, 08:19:10 PM
Quote from: gerw on January 24, 2009, 07:57:47 PM
Yes, it was. But I fixed (hardcoded) the starting point and the end point. Next step are alternating starting / end points.

That is indeed a good start :-) I wonder whether you could make the propensity for a river to have a source compatible with VS's pending weather system? That would be rather excellent. The end point should be a lot easier: any randomly selected bit of coastline should suffice.
Title: Re: Rivers development
Post by: gerw on January 24, 2009, 08:38:12 PM
Quote from: jamespetts on January 24, 2009, 08:19:10 PM
I wonder whether you could make the propensity for a river to have a source compatible with VS's pending weather system? That would be rather excellent.
I think this can be done easily by adopting the probabilities.
Title: Re: Rivers development
Post by: jamespetts on January 24, 2009, 08:43:22 PM
This looks very promising indeed :-) Bridges will *really* be useful now!
Title: Re: Rivers development
Post by: gerw on January 24, 2009, 08:50:15 PM
Currently, you can just remove a tile of the river ;) It's a canal build by the public player, but everyone can erase it...
Title: Re: Rivers development
Post by: VS on January 24, 2009, 08:57:57 PM
What I am planning - if I ever get to it - is that every tile gets a number describing its "water amount". For the climate purposes it is sorted into three categories, but it could be used directly when adding rivers. Anyway, I don't know how long will it take me to finish this, so...
Title: Re: Rivers development
Post by: gerw on January 24, 2009, 10:08:02 PM
Here comes a first - indeed very beta - patch for rivers. It will creates at most one river when creating a map, but sometimes it fails anyhow. It is very slow and sometimes the river isn't connected everywhere.

Feel free to test ;)
Title: Re: Rivers development
Post by: VS on January 24, 2009, 10:34:13 PM
So... you find peaks and from them run to random water tile?
Title: Re: Rivers development
Post by: jamespetts on January 24, 2009, 11:00:13 PM
Hmm, your code doesn't compile because the part in simmain.cc has problems with arrays that aren't dynamic being treated as if they were in places such as:


uint16 river_len = tmp->count+1;
koord river_route[river_len];


The second line produces the errors:


error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'river_route' : unknown size


Edit: Have fixed it by changing the following lines (old lines are commented out):


//uint32 MAX_NODES = 200000;
const uint32 MAX_NODES = 200000;
ANode nodes[MAX_NODES];



uint16 river_len = tmp->count+1;
//koord river_route[river_len];
vector_tpl<koord> river_route(river_len);



//sint8 river_hgt[river_len];
vector_tpl<sint8> river_hgt(river_len);
river_hgt[0] = lookup_hgt(river_route[0]);


Edit 2: Unfortunately, the first change produces a stack overflow: an array of 2,000 ANode type is evidently too much for my CPU! I am trying to make it work with a vector, but get out of bounds errors at present...

Edit 3: I have finally managed to get it working by converting all instances thus:


//ANode* tmp = &nodes[step];
ANode* tmp = new ANode;


And all instances thus (and similar):


//river_hgt[0] = lookup_hgt(river_route[0]);
river_hgt.insert_at(0, lookup_hgt(river_route[0]));


At present, I only get a large, sea-level river hewn out of the landscape: no canal-based shallower rivers. Is that intentional? Also, no matter how many rivers that I set it to create (by changing the number in the argument "create_rivers(uint8 number)" to 5), it creates only one.

Edit 4: I have managed to get it to create the correct number of rivers using a for loop in the rivers creation method, although that slows map initialisation a little. Still cannot get shallow rivers to work.
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 12:36:50 PM
Some screenshots from the rivers patch as currently released (and as I have fixed it):

Title: Re: Rivers development
Post by: Fabio on January 25, 2009, 12:44:37 PM
WOW, this is EXTREMELY promising... i really like it!!! thank you all!
Title: Re: Rivers development
Post by: VS on January 25, 2009, 12:50:08 PM
Errr... these steep valleys are a "fix" ?
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 12:52:23 PM
No, the steep valleys are not a fix that I have applied - they were part of how the patch worked. All that I did was fix the compile-time and run-time errors that made it not work at all: I didn't change the behaviour, except in relation to the number of rivers created. I think that the idea is to use canals as rivers at the higher altitudes, but that does not seem to be working in this version of the patch (see my previous post).
Title: Re: Rivers development
Post by: gerw on January 25, 2009, 12:59:35 PM
Quote from: jamespetts on January 24, 2009, 11:00:13 PM
Hmm, your code doesn't compile because the part in simmain.cc has problems with arrays that aren't dynamic being treated as if they were in places such as:
Ok. I set MAXNODES and river_len to const.

QuoteUnfortunately, the first change produces a stack overflow: an array of 2,000 ANode type is evidently too much for my CPU!
Mmh. This are only 22*200,000 bytes = 4,2 megabyte.

QuoteAlso, no matter how many rivers that I set it to create (by changing the number in the argument "create_rivers(uint8 number)" to 5), it creates only one.
This is the intended behaviour ;)


The flat rivers are caused by your changes.
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 01:04:08 PM
Gerw,

hmm, that's extremely odd. The patch that you uploaded did not have those values set to const, so I had to change them (and did indeed get a stack overflow). I managed to modify the river creation system to produce the number of rivers desired (with a simple for loop), but I'm not sure why my alterations have caused the rivers to go flat: as stated, the original version caused a stack overflow. Remember, 4.2Megabytes on the stack is a huge amount - most CPUs only have a cache memory of 512Kb!

Do you think that you could make a version that does not cause a stack overflow on computers that do not have CPUs with 4.2Mb of cache...?

Edit: Incidentally, I could only change one of them to const (even with the stack overflow): the other required me to use a vector, since the array size was set by a variable!
Title: Re: Rivers development
Post by: gerw on January 25, 2009, 01:06:45 PM
I mean, I changed the values to const in my current source code. And I think, the 4,2 megs aren't in the processors cache. Can you test the appended version?

Edit:
If it doesn't work, can you test:
ANode* nodes = new ANode[MAX_NODES];
for creating the ANode array?
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 01:14:10 PM
Gerw,

I've tested it: it still produces 6 compile errors:



1>.\simworld.cc(1066) : error C2057: expected constant expression
1>.\simworld.cc(1066) : error C2466: cannot allocate an array of constant size 0
1>.\simworld.cc(1066) : error C2133: 'river_route' : unknown size
1>.\simworld.cc(1075) : error C2057: expected constant expression
1>.\simworld.cc(1075) : error C2466: cannot allocate an array of constant size 0
1>.\simworld.cc(1075) : error C2133: 'river_hgt' : unknown size


The line numbers may differ from yours because my code is modified.
Title: Re: Rivers development
Post by: VS on January 25, 2009, 01:18:55 PM
Hardware stack on x86 is 64 kB if I am not totally out. Windows default stack is 1024 kB and maximal 32768 kB. I had this problem with Shades, too. Large data tasks can not be done with simple recursion, it seems.
Title: Re: Rivers development
Post by: gerw on January 25, 2009, 01:28:43 PM
Try this, evil tester ;)
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 01:34:51 PM
It compiles, but now I get an access violation at this line:


riverbuilder.baue();
Title: Re: Rivers development
Post by: gerw on January 25, 2009, 01:42:03 PM
Looks promising ;)
Which pakset are you using? Does this pakset have canals?
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 01:44:34 PM
Quote from: gerw on January 25, 2009, 01:42:03 PM
Looks promising ;)
Which pakset are you using? Does this pakset have canals?

I was using Pak128; I am not sure whether Pak128 has canals. I can try it again with Pak64, if that would help? But there needs to be a solution for paksets without canals...

Edit: Same result with Pak64. Have you tried this in a debugger...?

Edit 2: No access violation with PakGerman (which does have canals), but also no rivers (of any type)...

Edit 3: Pak96.Comic produced no access violation, and did indeed produce a "river": made entirely of what it describes as an "extended field path", which looks like a thin, brown, muddy track...
Title: Re: Rivers development
Post by: gerw on January 25, 2009, 01:49:10 PM
It works fine for me with pak.german, pak64 and pak.comic. But it fails with pak.HAJO. Can you try this patch?

Edit: changed patch file
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 01:59:12 PM
I still get an access violation with Pak128 and Pak64. PakGerman now produces a river that is canal-based for its entire length, but all the slopes are represented as locks. Pak96.Comic produced another long country path based river. PakBritain gave an access violation.

Is it not possible to have a happy medium between a sea-based river for the entire length, and a canal based river for the entire length? Some rivers do indeed form in deep gorges, whereas some are small streams...

Edit: Incidentally, have you made any changes other than to the create_rivers method? I ask because I have to apply your patch manually - TortoiseSVN isn't working well for me, because my code is heavily modified.
Title: Re: Rivers development
Post by: gerw on January 25, 2009, 02:03:43 PM
Quote from: jamespetts on January 25, 2009, 01:59:12 PM
I still get an access violation with Pak128 and Pak64. PakGerman now produces a river that is canal-based for its entire length, but all the slopes are represented as locks. Pak96.Comic produced another long country path based river. PakBritain gave an access violation.
Can you debug this?

QuoteIs it not possible to have a happy medium between a sea-based river for the entire length, and a canal based river for the entire length? Some rivers do indeed form in deep gorges, whereas some are small streams...
This is desired. But it is a long way to this ;)

QuoteEdit: Incidentally, have you made any changes other than to the create_rivers method? I ask because I have to apply your patch manually - TortoiseSVN isn't working well for me, because my code is heavily modified.
Please use a 'fresh' version for testing and debugging!
Title: Re: Rivers development
Post by: VS on January 25, 2009, 02:14:46 PM
You can do another checkout. Or copy your current one and revert.
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 02:23:27 PM
Debugging:

the access violation occurs here:


uint8 karte_t::sp2num(spieler_t *sp)
{
if(  sp==NULL  ) {
return PLAYER_UNOWNED;
}
for(int i=0; i<MAX_PLAYER_COUNT; i++) {
if(spieler[i] == sp) {                          <<<<<<<<<<<<<<THIS LINE
return i;
}
}
dbg->fatal( "karte_t::sp2num()", "called with an invalid player!" );
}


(The line one on which it occurs is marked). "Sp" is a valid value, but "Speiler" is empty. That is called from void ding_t::set_besitzer(spieler_t *sp), which in turn is called from the line "weg->calc_bild();" in long grund_t::neuen_weg_bauen(weg_t *weg, ribi_t::ribi ribi, spieler_t *sp), which in turn is called from the line "cost = -gr->neuen_weg_bauen(sch, ribi, sp)-besch->get_preis();" in voidwegbauer_t::baue_schiene(), which in turn is called from the line "baue_schiene();" in void wegbauer_t::baue(), which is called by riverbuilder.baue(); in your method.

As to the checkouts and versions - I am currently trying to set up a DVCS for Simutrans-Experimental, so that I can revert the SVN to the default Simutrans to be able to test individual small changes, but I am having considerable trouble making DVCS work at all.
Title: Re: Rivers development
Post by: VS on January 25, 2009, 02:39:56 PM
Well, "this" seems to be NULL, so you probably have invalid karte to begin with.

EDIT: Oh yes, it seems the ding (weg?) does not have set a local "welt", so it can not look up the player, that's why it dies there.

EDIT2: Gotcha. wegbauer.cc, line 1956 is where the weg (here called "sch") is created; going into it, suddenly, static member "welt" is nothing... why?

EDIT3: Mwahahahaha. I may be wrong, but the weg_t class does initialize its static welt (through ancestor ding_t) only once it is created for first time with this parameter. My theory is that it does not happen before creation of rivers and thus the fake weg_t instance used for estimating costs of destroying trees(?) does not know its welt. I will try to create an object "just for the sake of it" and see if it fixes that.

EDIT4: Har har. I am the winner, until we discover the running pointers everywhere ;)

if(  true  ) { // Generating of rivers.
baum_t b = baum_t(this, koord3d());
create_rivers(1);
}
Title: Re: Rivers development
Post by: gerw on January 25, 2009, 03:46:29 PM
Thank you VS, for figuring this out. Maybe a line like this will fix it?
schiene_t dummy(this);

By the way, simutrans got a new feature: lake in a river ;)

[attachment deleted by admin]
Title: Re: Rivers development
Post by: VS on January 25, 2009, 03:51:54 PM
Ah, sure, see my edit #5. Any convenient object will do.
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 04:01:26 PM
There are only 4 edits...

Edit: In any event, VS's patch has fixed the access violations, although we now still have only canal type rivers...
Title: Re: Rivers development
Post by: VS on January 25, 2009, 04:26:19 PM
To be honest, gerw got there first.

And there really are just 4 edits, I meant the last one.

It might be nice to walk the "route" backwards and instead of laying canals lower the first, say, 1/10 tiles.
Title: Re: Rivers development
Post by: gerw on January 25, 2009, 04:32:10 PM
Quote from: VS on January 25, 2009, 04:26:19 PM
It might be nice to walk the "route" backwards and instead of laying canals lower the first, say, 1/10 tiles.

Of course, I want to do something like this.
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 04:34:29 PM
The flat version that I accidentally got when trying to make the original version work produced lovely valleys, but one wouldn't want them everywhere that there are rivers. It would be useful to have code that does some flattening (and puts a canal at the bottom), but not flattening everything to sea level. Near the mouth of the river, it would be flattened to sea-level, and create an estuary.
Title: Re: Rivers development
Post by: gerw on January 25, 2009, 04:39:07 PM
You two are very impatient ;)

I'll type the patch as fast as I can  :)
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 04:41:12 PM
Sorry for being impatient - it's just that we love the rivers patch! ;-)
Title: Re: Rivers development
Post by: VS on January 25, 2009, 05:13:35 PM
I can wait. It was a mere suggestion ;)
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 05:18:50 PM
Quote from: VS on January 25, 2009, 05:13:35 PM
I can wait.

Speak for yourself ;-)
Title: Re: Rivers development
Post by: gerw on January 25, 2009, 05:31:23 PM
Now, rivers have a river bed all over their length (is this nice?) and the last 1/4 is lowered to sea level.
Title: Re: Rivers development
Post by: sojo on January 25, 2009, 06:37:04 PM
Can you put a screenshot to the patch? So the not-programmer can see what is new.
Title: Re: Rivers development
Post by: Fabio on January 25, 2009, 07:42:46 PM
Quote from: gerw on January 25, 2009, 05:31:23 PM
Now, rivers have a river bed all over their length (is this nice?)
i think it's just perfect

Quote from: gerw on January 25, 2009, 05:31:23 PM
and the last 1/4 is lowered to sea level.
great!

Quote from: sojo on January 25, 2009, 06:37:04 PM
Can you put a screenshot to the patch? So the not-programmer can see what is new.
pleeeeeeeeeeeeeeease!!!!!! we common sithaners can't wait!!!
Title: Re: Rivers development
Post by: IgorEliezer on January 25, 2009, 08:01:08 PM
Quote from: fabio on January 25, 2009, 07:42:46 PM
pleeeeeeeeeeeeeeease!!!!!! we common sithaners can't wait!!!

*Igor waves his hands *
Title: Re: Rivers development
Post by: jamespetts on January 25, 2009, 08:45:05 PM
Some screenshots of the new rivers code (with my change to allow multiple river generation). Looking very good so far, but still needs some slight tweaking, I think: (1) there are some graphical glitches with canals in places (some can be seen in the screenshot); (2) the canals used for rivers should somehow be renamed to "river" rather than "canal", without stopping people from using canals called "canals" in the game (this will require a pakset implementation, I think); (3) it would be good if rivers could have wider estuaries, and also, if the size (length and width) of their estuary could depend on the river's total length, so as to have a mixture of small and large rivers, just as in reality, and to provide good visual variety; (4) rivers can currently be removed (!) using the remove tool, which is not ideal; and (5) there needs to be a way of setting the number of rivers produced at map generation in the "new map" GUI.

Having said that, though, the rivers patch is a very significant advance for Simutrans. Excellent work!
Title: Re: Rivers development
Post by: sojo on January 25, 2009, 08:54:34 PM
This looks nice. But the land should more flat. Mostly is the waterside only a little higher than the water.
Title: Re: Rivers development
Post by: gauthier on January 25, 2009, 09:47:11 PM
I'm just waiting until the implementation of this patch in nightly version  ;)

...
...

WONDERFUL ! AWESOME ! MAGNIFICAL ! SUPER !
Title: Re: Rivers development
Post by: wernieman on January 25, 2009, 10:02:39 PM
When you think, that the path is ready for testing, can you send me a PM?
Title: Re: Rivers development
Post by: vilvoh on January 25, 2009, 10:08:28 PM
Simply awesome!!...(http://www.greensmilies.com/wp-content/uploads/2008/03/elffyfav.gif)
Title: Re: Rivers development
Post by: The Hood on January 25, 2009, 10:10:42 PM
This is one of the best additions I have seen for ages - well done!  I hope you can iron out all the last bits of problems without too much hassle!
Title: Re: Rivers development
Post by: jamespetts on January 26, 2009, 12:31:15 AM
Another suggestion for refinement: it would be good if there was a way of detecting when the rivers joined each other. Currently, one river does not take account of the presence of another (I know I am using my own hacked code to implement multiple rivers in a very simple way - perhaps this was planned for multiple rivers in any event). But it would be rather lovely if, not only did multiple rivers join into one whenever their paths crossed, but if the resulting estuary was twice (or three or four times, etc., depending on the number of tributaries) as big as an estuary from a single river (that is, both longer and wider at the sea end).

But, I should repeat, excellent work. This is a very important and exciting advance for Simutrans.
Title: Re: Rivers development
Post by: Magic_Gorter on January 26, 2009, 07:21:47 AM
Never thought that this development would go this fast. Great job. I really hope it will be part of simutrans soon.
Title: Re: Rivers development
Post by: Fabio on January 26, 2009, 10:25:08 AM
Quote from: jamespetts on January 25, 2009, 08:45:05 PM
(2) the canals used for rivers should somehow be renamed to "river" rather than "canal", without stopping people from using canals called "canals" in the game (this will require a pakset implementation, I think);

For pak 128 i could take care of it, as i did for canals, once i know what it's exactly needed. I would suggest a canal named River and with NO icon, as cityroads used to be, or an icon only visible in map editing menu of public player (this would be indeed the best option).

Quote from: Magic_Gorter on January 26, 2009, 07:21:47 AM
Never thought that this development would go this fast.

In a way i knew that the basics were already there, but i never hoped to see such a GREAT result in such a short time!
Congratulation, buddies!
Title: Re: Rivers development
Post by: Spike on January 26, 2009, 10:32:41 AM
Great :)

Rivers have been something that I wanted in Simutrans since a very long time. Thanks for the addition!
Title: Re: Rivers development
Post by: gerw on January 26, 2009, 11:08:46 AM
Again: Multiple rivers aren't supported yet.

And of course, we need new graphics for the rivers. Maybe even waterfalls which can't be used by ships? I will talk to prissi, how to do this.
Title: Re: Rivers development
Post by: prissi on January 26, 2009, 11:25:05 AM
I had a look at the patch: Some comments would help to figure out, what is actually going on.

The river length should most likely depend on the map size, imho. Also a binary heap is overkill, if you are doing a random walk in the cost function. (I am not even sure this a a valid way to do the way search.) Maybe just a much more simple random walk would suffice too ...
Title: Re: Rivers development
Post by: gerw on January 26, 2009, 12:00:56 PM
Quote from: prissi on January 26, 2009, 11:25:05 AM
I had a look at the patch: Some comments would help to figure out, what is actually going on.
Indeed. I will comment the patch, if it is already complete.

QuoteThe river length should most likely depend on the map size, imho.
That is a good idea.

QuoteAlso a binary heap is overkill, if you are doing a random walk in the cost function. (I am not even sure this a a valid way to do the way search.) Maybe just a much more simple random walk would suffice too ...
It's not a simple random walk. It's a route search on a graph, where the weights have a random addend and therefore it is valid. This is needed to get curved rivers.
Title: Re: Rivers development
Post by: prissi on January 26, 2009, 03:15:19 PM
I had a deeper look now. Most of the stuff imho belongs to waybuilder, it reülicates stuff already there. Here the version I indend to submit. (Number of rivers is now the square root of the number of towns). Again to clarify: THis is mostly your code cleaned up and made a little faster. Still some issues to fix are left.


Title: Re: Rivers development
Post by: VS on January 26, 2009, 04:02:28 PM
Two side comments, not directly related to the patch itself:
Title: Re: Rivers development
Post by: Fabio on January 26, 2009, 04:17:26 PM
Quote from: VS on January 26, 2009, 04:02:28 PM

  • Cities do not build bridges, so sometimes they are cut in half...

Could the cities build bridges? (with a patch) It would make sense. Most of RL cities grow along a river...


Quote from: VS on January 26, 2009, 04:02:28 PM

  • Intercity roads have hard times ;) In 128 are water crossings, so it works, but what about other paks?

Could intercity roads build bridges? IIRC, once upon a time, the waybuilder used to build bridges automatically. this would be great at least for starting intercity connections.
Title: Re: Rivers development
Post by: The Hood on January 26, 2009, 04:58:21 PM
I agree with Fabio - it seems daft that cities can't even build bridges over railways so they can't expand beyond the very thing bringing them economic prosperity!
Title: Re: Rivers development
Post by: Fabio on January 26, 2009, 05:06:56 PM
Quote from: The Hood on January 26, 2009, 04:58:21 PM
I agree with Fabio - it seems daft that cities can't even build bridges over railways so they can't expand beyond the very thing bringing them economic prosperity!

this is off topic: when i build a new railways line, i also provide a few bridges for the city to grow. Also in RL, a bridge over a railway can't be built without a previous agreement with the transport company. Totally different the issue with bridges: cities SHOULD (if not too hard to code) grow across rivers, and rivers are public, so the cities don't have to ask for permission  ;)
Title: Re: Rivers development
Post by: jamespetts on January 26, 2009, 05:11:45 PM
About bridges - when rivers are represented as canals, the "bridge" is just a graphic for a level crossing, so, to the game, it is not building bridges - it is building level crossings. It would be good if it were possible to have a separate cost for these quasi-bridges, and to make them more expensive than level crossings for roads.

As to Prissi's calculation of the number of rivers - ought this not be set as one of the options in the "New World" dialogue, rather than being fixed as the square root of the number of towns?
Title: Re: Rivers development
Post by: gerw on January 26, 2009, 05:19:05 PM
Quote from: prissi on January 26, 2009, 03:15:19 PM
I had a deeper look now. Most of the stuff imho belongs to waybuilder, it reülicates stuff already there. Here the version I indend to submit. (Number of rivers is now the square root of the number of towns). Again to clarify: THis is mostly your code cleaned up and made a little faster. Still some issues to fix are left.
Thank you for your reply. Indeed, I doubled some of the stuff from wegbauer (unconsciously). But with your changes it is not possible to merge rivers and let them have a bigger river delta or something like that.
Title: Re: Rivers development
Post by: prissi on January 26, 2009, 05:24:23 PM
It is possible, all depending on start end endpoint. A wider delta would be possible too. Also would be later contruction like with the waytool be possible ...

And intercity bridges are possible, since those roads belong to the public player. The only problem was, that with bridges the way search is much much slower.
Title: Re: Rivers development
Post by: VS on January 26, 2009, 06:05:17 PM
So a better solution is just to provide canal/road crossings for pak64.
Title: Re: Rivers development
Post by: Fabio on January 26, 2009, 07:22:50 PM
Quote from: jamespetts on January 26, 2009, 05:11:45 PM
About bridges - when rivers are represented as canals, the "bridge" is just a graphic for a level crossing, so, to the game, it is not building bridges - it is building level crossings. It would be good if it were possible to have a separate cost for these quasi-bridges, and to make them more expensive than level crossings for roads.

As to Prissi's calculation of the number of rivers - ought this not be set as one of the options in the "New World" dialogue, rather than being fixed as the square root of the number of towns?

I support this idea.
And IMHO the MAX length of a river should be set to half of the shortest side of a map (e.g. 512*512 -> 256)


Quote from: prissi on January 26, 2009, 05:24:23 PM
And intercity bridges are possible, since those roads belong to the public player. The only problem was, that with bridges the way search is much much slower.

Well, if the new world routines are only cast at the beginning of the game, a long map generation wouldn't have effect on the normal gameplay...
Title: Re: Rivers development
Post by: gerw on January 26, 2009, 08:16:37 PM
Quote from: fabio on January 26, 2009, 07:22:50 PM
And IMHO the MAX length of a river should be set to half of the shortest side of a map (e.g. 512*512 -> 256)
I think so, too. Long rivers become looking ugly.
Title: Re: Rivers development
Post by: jamespetts on January 26, 2009, 09:18:51 PM
I am not so sure about long rivers - there are many places in the world (most notably, the Amazon) in which rivers start near one coast, but go the "wrong" way, and end up crossing much of the country to find their way to the other coast. Perhaps the maximum length could be adjustable?
Title: Re: Rivers development
Post by: prissi on January 26, 2009, 09:38:17 PM
I would ask to focus first on the task of rivers per se. That there is an UI needed comes without question.
Title: Re: Rivers development
Post by: gerw on January 26, 2009, 10:28:03 PM
@prissi: Your routine will fail to create rivers on a map with mountain height 320 and roughness 6. This is caused by the fact, that the route of the river must have already the right shape.

With my code this is not necessary, since the river forms the landscape. But I think, this can also be done by wegbauer, if we include all my magic loops ;)

[attachment deleted by admin]
Title: Re: Rivers development
Post by: vilvoh on January 26, 2009, 10:35:26 PM
OMG!...that picture looks awesome!!! this patch has become as popular as the overtaking fun patch..
(http://www.greensmilies.com/smile/smiley_emoticons_megaeek.gif)

P.S: count with me if you finally need graphics for waterfalls and springs...would be a pleasure to take part on this.
Title: Re: Rivers development
Post by: jamespetts on January 27, 2009, 12:26:50 AM
Ohh, I think that rivers are even better than overtaking ;-)
Title: Re: Rivers development
Post by: sojo on January 27, 2009, 07:16:28 AM
Can be at the beginning of the river a sea or a smaller part river?

PS. This looks very very nice.
Title: Re: Rivers development
Post by: wernieman on January 27, 2009, 08:07:21 AM
I make a special run with prissis patch .... I whant to see if it compile correct

somebody interessted to test?

Ore should I wait the next patch?
Title: Re: Rivers development
Post by: sojo on January 27, 2009, 08:37:12 AM
Quote from: wernieman on January 27, 2009, 08:07:21 AM
somebody interessted to test?
Yes.
Title: Re: Rivers development
Post by: wernieman on January 27, 2009, 08:44:05 AM
What do you pay ....  8)
Title: Re: Rivers development
Post by: gerw on January 27, 2009, 09:02:30 AM
Quote from: wernieman on January 27, 2009, 08:07:21 AM
Ore should I wait the next patch?
If you can wait until evening, I will post a new version of prissis patch.

I think further, I will couple the number of rivers with the map size until we have a UI input for this.
Title: Re: Rivers development
Post by: sojo on January 27, 2009, 09:05:24 AM
Quote from: wernieman on January 27, 2009, 08:44:05 AM
What do you pay ....  8)
Here. You can have a lot of simuthanian Credits.
Title: Re: Rivers development
Post by: vilvoh on January 27, 2009, 09:24:21 AM
Quote from: wernieman on January 27, 2009, 08:44:05 AM
What do you pay ....  8)

(http://www.greensmilies.com/smile/smiley_emoticons_cash2.gif)..(http://www.greensmilies.com/smile/smiley_emoticons_cash2.gif).... Is it enough with that?
Title: Re: Rivers development
Post by: wernieman on January 27, 2009, 11:11:26 AM
Look at http://patches.simutrans-germany.com/ (http://patches.simutrans-germany.com/)

But it is only "Prissis-Patch". If I should run an other Version ... cry

Importend:
I don´t testet it!

Edit:
But it is only the Program! So you need a full simutrans + PAK to run it
Title: Re: Rivers development
Post by: vilvoh on January 27, 2009, 12:08:42 PM
Does Windows versions also include the patch?
Title: Re: Rivers development
Post by: wernieman on January 27, 2009, 12:10:54 PM
Jep .. I only forget to write it ....
every 4 Versions have the patch
Title: Re: Rivers development
Post by: vilvoh on January 27, 2009, 12:14:11 PM
Thanks for the info, and for the compilations too.... ;D
Title: Re: Rivers development
Post by: sojo on January 27, 2009, 01:50:51 PM
I have it tried with pak96.comic. Very very nice.

One question: Can the rivers at the lowest level be bigger. Mayby 2 tiles or 3 tiles?
Title: Re: Rivers development
Post by: IgorEliezer on January 27, 2009, 02:00:26 PM
I think river width should be in function of river length. The more long the river is, the more wider it will be. Not in function of altitude.
Title: Re: Rivers development
Post by: sojo on January 27, 2009, 02:09:27 PM
A long river have the same width like a short river.

But i think it should easy to say, if a river on level 1 or 0 ( I dont' know the levels) then it is 2 tiles width.
Title: Re: Rivers development
Post by: IgorEliezer on January 27, 2009, 02:29:29 PM
Quote from: sojo on January 27, 2009, 02:09:27 PM
A long river have the same width like a short river.

Nothing is born big ;) .
Title: Re: Rivers development
Post by: Fabio on January 27, 2009, 03:30:46 PM
Rivers for PAK 128 are READY!!!

(http://photos-b.ak.fbcdn.net/photos-ak-snc1/v2103/109/2/570648252/n570648252_1335961_1764.jpg)
(http://photos-c.ak.fbcdn.net/photos-ak-snc1/v2103/109/2/570648252/n570648252_1335962_2007.jpg)
(http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2103/109/2/570648252/n570648252_1335963_2237.jpg)
(http://photos-e.ak.fbcdn.net/photos-ak-snc1/v2103/109/2/570648252/n570648252_1335964_2477.jpg)

what do you think?
Title: Re: Rivers development
Post by: KrazyJay on January 27, 2009, 03:32:06 PM
 Looks great! Will there be a tool to change/modify those rivers?
Title: Re: Rivers development
Post by: Fabio on January 27, 2009, 03:33:40 PM
ATM they are only a new channel named river.
It's up to the DEVs to handle them. once i have a few more feedback, i'll post the sources...
Title: Re: Rivers development
Post by: jamespetts on January 27, 2009, 03:40:02 PM
That looks very good! Do you have any screenshots of roads and railways crossing the rivers?
Title: Re: Rivers development
Post by: The Hood on January 27, 2009, 08:47:22 PM
Very impressive!  I would just say that it depends on your road waybuilding settings in simuconf.tab (in case anyone else has this problem?)

To start with I kept getting very short stubby rivers only, until I used the waybuilder settings in the latest pak128 simuconf.tab.
Title: Re: Rivers development
Post by: prissi on January 27, 2009, 08:52:44 PM
The length mostly depends on your landscape.
Title: Re: Rivers development
Post by: gerw on January 27, 2009, 09:00:25 PM
New revision of the patch. Now rivers will join each other. Unless there is a UI interface 20 rivers are created.
Title: Re: Rivers development
Post by: The Hood on January 27, 2009, 09:52:18 PM
Quote from: prissi on January 27, 2009, 08:52:44 PM
The length mostly depends on your landscape.

Yes - but this was on identical maps with otherwise identical settings.  It's all fixed anyway :-) - I just mentioned it in case anyone else gets that problem (especially if they are using older paksets with older simuconf.tabs like I was to start with).
Title: Re: Rivers development
Post by: prissi on January 27, 2009, 09:56:49 PM
Ok, UI still lacks but gerw rivers (with a little cleaning up and some additions to avoid flowing uphills) they are in the trunk. In principle the waybuilder tool could be done with rivers too. (Also the preview woul be no good then.)

[attachment deleted by admin]
Title: Re: Rivers development
Post by: z9999 on January 27, 2009, 10:11:55 PM
Please add UI on final version.
Because people who use height maps don't want random rivers which don't exist there.
Title: Re: Rivers development
Post by: jamespetts on January 27, 2009, 11:21:35 PM
That screenshot looks very promising - I love the merging rivers, and the variable length estuaries! (Although, variable width estuaries would also be good...)
Title: Re: Rivers development
Post by: prissi on January 28, 2009, 09:02:12 AM
There is already an UI in the trunk.
Title: Re: Rivers development
Post by: Fabio on January 28, 2009, 09:54:56 AM
@ jamespetts:
(http://photos-b.ak.fbcdn.net/photos-ak-snc1/v2103/109/2/570648252/n570648252_1338361_2547.jpg)

Title: Re: Rivers development
Post by: sojo on January 28, 2009, 10:13:48 AM
This is a crossing. Whould a bridge looks nicer? It is possible to let the programm build a bridge?

PS. I'm very happy with the new rivers. Thank you gerw and prissi. For more screenshot look at http://forum.simutrans.com/index.php?topic=37.msg13432#msg13432
Title: Re: Rivers development
Post by: squeaky on January 28, 2009, 12:00:43 PM
would it be possible to make rivers not navigable but make it cheaper to change rivers to canals than start canals fresh?
Title: Re: Rivers development
Post by: Fabio on January 28, 2009, 03:10:02 PM
Quote from: squeaky on January 28, 2009, 12:00:43 PM
would it be possible to make rivers not navigable but make it cheaper to change rivers to canals than start canals fresh?

Rivers not navigable: not hard, if in your pakset you ste max speed=1 and maxweight=1, for sure they are uneconomical to navigate.
But upgrading them to canals it costs as much as lying a whole new canal, as it happens for roads and railways. once it was discussed to pay less to upgrade ways, but it has been rejected long ago. (But you can talk about this with James Petts, maybe he's interested in this for his Experimental Simutrans)
Title: Re: Rivers development
Post by: IgorEliezer on January 28, 2009, 03:36:04 PM
For me, it would be interesting even if rivers start from a stream source (headwater (http://en.wikipedia.org/wiki/Source_(river_or_stream))) than a channel.

Obviously that stream would not be navigable.
Title: Re: Rivers development
Post by: jamespetts on January 28, 2009, 09:11:52 PM
Yes, some rivers are navigable, and others are not. Weight is probably a sensible way of distinguishing between them - a weight limit of 1 will mean that not much bigger than a small pleasure boat could get up the river at any sensible speed, which is enough of a restriction for commercial purposes.
Title: Re: Rivers development
Post by: Dwachs on January 29, 2009, 07:37:36 AM
Very nice feature! gerw and little prissi: thank you for implementing!
Title: Re: Rivers development
Post by: whoami on January 29, 2009, 12:16:29 PM
Quote from: jamespetts on January 28, 2009, 09:11:52 PM
Weight is probably a sensible way of distinguishing between them - a weight limit of 1 will mean that not much bigger than a small pleasure boat could get up the river at any sensible speed, which is enough of a restriction for commercial purposes.
Small boats for passengers and mail could still travel over small rivers.
But hovercrafts can pass the most shallow water, they can even master land, so the weight limit would restrict these more than necessary.
Title: Re: Rivers development
Post by: VS on January 29, 2009, 01:05:14 PM
Then just make them light?
Title: Re: Rivers development
Post by: whoami on January 29, 2009, 01:31:54 PM
Weight is also used for acceleration, so the effective power would have to be lowered by magnitudes.
Title: Re: Rivers development
Post by: Fabio on January 29, 2009, 02:07:43 PM
Quote from: whoami on January 29, 2009, 01:31:54 PM
Weight is also used for acceleration, so the effective power would have to be lowered by magnitudes.
couldn't acceleration be lowered using the gear ratio?
Title: Re: Rivers development
Post by: VS on January 29, 2009, 03:01:49 PM
Whoami said "effective power", so I assume he already meant that. Anyway, that would make the vehicle either crawl when loaded, or rocket-start when empty, as the difference between loaded and empty weight would increase a lot.

For starters, I would go for a simple system using a special canal version called "river", just as fabio created for 128, with no strings attached. Also I'd like to remind that pak64 must be in this sense feature-complete, since that is the official testing data set.
Title: Re: Rivers development (was: Rivers)
Post by: IgorEliezer on January 29, 2009, 03:09:11 PM
In order to avoid confusions with similar topics in Pak128 and Pak96 boards, I renamed the topic.

Have fun. :)
Title: Re: Rivers development
Post by: wernieman on January 29, 2009, 03:56:14 PM
In the nightly PAK64 (Tomorow) is a River ....

(I look at the SVN)
Title: Re: Rivers development
Post by: vilvoh on January 30, 2009, 09:20:12 AM
One suggestion: would be possible to have different river's graphics according to the different existing climates in Simutrans? i.e. frozen river for tundra, river with ice plates for artic, river with green water for tropical, etc..imho, It would add more variety and realism to landscapes.
Title: Re: Rivers development
Post by: prissi on January 30, 2009, 11:16:16 AM
Way can have winter images since ages ... Apart from than no, and since those are vanilla way graphcis will not be considered for inclusion.

(You greedy guys: River are not yet finished and still you damand the next feature! ;) )
Title: Re: Rivers development
Post by: Fabio on January 30, 2009, 11:32:58 AM
Quote from: prissi on January 30, 2009, 11:16:16 AM
Way can have winter images since ages ...

present time river in pak 128 (which will soon be changed) has already winter graphs...
Title: Re: Rivers development
Post by: vilvoh on January 30, 2009, 12:05:16 PM
I'll take that as a NO... ::)....*vilvoh starts drawing sketches of winter rivers*
Title: Re: Rivers development
Post by: Colin on February 01, 2009, 12:00:39 AM
Rivers in latest PAK64-130!!! BRILLIANT.
Title: Re: Rivers development
Post by: jamespetts on February 01, 2009, 12:03:29 AM
I have to say - I am very impressed with the speed and quality of the development of this feature. It is a major addition to Simutrans.
Title: Re: Rivers development
Post by: prissi on February 01, 2009, 11:43:29 AM
The rivers in pak64 are not very nice. It would be nice to have at least 3 different river types, gradually increasing, with the smallest type not straight but meandering (curve) with some grass etc. I know what I mean, I hope.

Same is true for the other paksets too, I presume.
Title: Re: Rivers development
Post by: gerw on February 01, 2009, 11:55:47 AM
Quote from: prissi on February 01, 2009, 11:43:29 AM
I know what I mean, I hope.
;)
Title: Re: Rivers development
Post by: z9999 on February 01, 2009, 12:00:23 PM
I don't make a bug report, but sometimes freeze and rarely quit without any error dialog during creating rivers.
I waited more than 5 minutes but didn't progress.
Title: Re: Rivers development
Post by: Fabio on February 01, 2009, 12:15:56 PM
Quote from: prissi on February 01, 2009, 11:43:29 AM
Same is true for the other paksets too, I presume.

I'm making rivers for pak128 this way, but it takes time... they'll be ok in a short time, though
Title: Re: Rivers development
Post by: jamespetts on February 01, 2009, 03:36:39 PM
Fabio,

I shall very much look forward to those rivers! I have been testing the rivers in the latest Pak64, and one of the things that I like about those rivers is that one cannot build a crossing over them: one is forced to build a proper bridge. Do you think that it would be possible to put that into the Pak128 rivers, too?
Title: Re: Rivers development
Post by: DirrrtyDirk on February 01, 2009, 03:45:08 PM
That would not require putting something into pak128, but to remove something from it (= crossings for waytype water with both track and road), I think...
Title: Re: Rivers development
Post by: jamespetts on February 01, 2009, 04:00:39 PM
Ahh, I see. Could that be done?
Title: Re: Rivers development
Post by: DirrrtyDirk on February 01, 2009, 05:43:30 PM
Why? It would also affect canals - and those crossings were added to the game on purpose. Besides, if we'd take them out, all savegames that are already using them would no longer work (properly) - so: no, it can't be (easily) done, I'm afraid.

However you can remove them from your personal copy of pak128 with only minimal effort.
Title: Re: Rivers development
Post by: Fabio on February 01, 2009, 09:48:08 PM
IN PAK64, rivers have something like system...=255. I'll put it also for pak 128, but i honestly don't recall what is it for... maybe it implies something with crossings too. By the way, i'm also thinking of a better crossing for road/water, maybe this would look better.


Quote from: jamespetts on February 01, 2009, 03:36:39 PM
Fabio,
I shall very much look forward to those rivers!

thank you, i hope the outcome will match the expectations!!!