News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Scripted map generation

Started by Dwachs, November 05, 2012, 08:08:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dwachs

Here is some proof-of-concept of using scripts to generate maps (aka placing cities and adjusting water level).

Example map-files can be found here:
https://github.com/Dwachs/simutrans-scenarios/tree/poland_map/maps

Here is a sample file placing some Polish cities at correct locations:

heightmap = "poland319x214.ppm"

settings.water_height = 0

create_city("Warszawa", 210, 89, 2345)
create_city("Krakow", 201, 161, 1234)
create_city("Poznan", 100, 81, 1234)
create_city("Bydgoszcz", 130, 48, 1234)
create_city("Szczeczin", 47, 47, 2345)
create_city("Bialystok", 292, 52, 2345)
create_city("Wroclaw", 110, 128, 2345)
create_city("Legnica", 70, 115, 2345)
create_city("Olsztyn", 193, 36, 2345)
create_city("Gdansk", 155, 24, 2345)


River generation by script is a pain, as the available heightfield data it too rough. More thoughts needed.
Parsley, sage, rosemary, and maggikraut.

VS

I am not looking at patch, so perhaps a dumb question - why the declarative/imperative mix?

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!

Dwachs

It happened to be like this. No idea why, no thoughts put into this.

What is easier to grasp for the potential script writer:

set_water_level( 2 )
create_city("City", ...)

or

water_level = 2
create_city("City", ...)

?
Parsley, sage, rosemary, and maggikraut.

Combuijs

I think your proof of concept with map, water level and cities looks really good, practical and extendable. Is it already working in Simutrans 112.0?

Can't restrain excitement...
Bob Marley: No woman, no cry

Programmer: No user, no bugs



VS

Maybe newbies would not mind at all, and it is just me, with years of conditioning to the two syntax paradigms, always unmixable?

I believe the confusion comes from not knowing whether to treat this as sequential commands that get executed, or just a fancy list of options.




I don't mean to criticize the effort, though - just weirded out, that is all. What this enables is really important and exciting!

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

Rivers could be a polygonal list of coordinates (x1, y1, x2, y2, ..., xn, yn), then the way builder performs the needed terraforming and places the river way.  It might be indicated where rivers must get wider as well.

Sarlock

Great work!

I can see rivers being very tricky to implement...
Current projects: Pak128 Trees, blender graphics

IgorEliezer

Just a crazy idea: What about a minimalistic heightmap editor? Something like Tilecutter interface but way simpler.

You load the ppm or image which is displayed in a window. Then by buttons ("Add City", "Add River" etc) or by commands ("/add city <name> <param1> <param2> ....") entered in a field, the editor would create and edit the script. Points for cities and rivers would be defined by clicking on the map.

If we desire something more fancier, this editor would have 2 toggleable layers: one would be the actual ppm, the other would be an overlay image, for example, if I want to create a script for a country, I'd load a real map over the ppm so I'd be able to see where the cities and rivers are in real life and use their positions to create the script.

prissi

Maybe (as suggested in the other thread) to use always 10000 by 10000 corrdinates, which then were scaled to the real map size (and same for inhabitants). THat way scaled down heightmaps would use the same files.

And I think as VS said, consequently "command(parameters)" is best way.

Carl

Just to say this is a really exciting feature -- and one that would have saved me countless hours on some of my projects! :)

Fabio

Maybe maps could even be scaled on the fly using simple interpolation, so that if I download, say, a 1024*4096 UK map I can then play it at whatever map size I like just preserving proportions.

Combuijs

Quote from: Fabio on November 06, 2012, 10:06:37 AM
Maybe maps could even be scaled on the fly using simple interpolation, so that if I download, say, a 1024*4096 UK map I can then play it at whatever map size I like just preserving proportions.

But if maps don't have the same proportions, they will most likely have a different area of the country. If you look at all British maps in Simutrans Maps you can't use one citylist and interpolate because they don't contain the same area. Imagine Blackpool falling in the sea...
Bob Marley: No woman, no cry

Programmer: No user, no bugs



Fabio

If the position (and dimension) is relative, the map can be scaled up or down containing exactly the same area, only at a different "zoom level".

Ters

I think you might still end up with cities in the sea if the land it's supposed to be on is interpolated away.

Fabio

Well, city builder should check that and either remove that city, either place it on nearest land shore.