Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Jun 25, 2018 6:14 am

All times are UTC




Post new topic  Reply to topic  [ 27 posts ]  Go to page 1 2 Next
Author Message
PostPosted: Thu Jun 21, 2012 7:12 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Jun 29, 2006 8:36 am
Posts: 259
Hi all,

Ive been playing around with fractal algorithms to create heightmaps for ottd. Especially the 1 height difference limit makes it hard to have nice looking mountains (with peaks) in the game. I wrote a map generator using the plasma fractal (random midpoint displacement), while forcing it to make water edges to get some big continental shapes. Tell me what you think, I myself am quite happy with how mountain ranges look while still enough flat land to have a playable scenario.

Ingame example:
Attachment:
File comment: Ingame shot of a mountain range
screenshot#13.png [200.87 KiB]
Downloaded 13 times


The GUI should be really intuitive. Select some parameters, seeds and generate until you see something that suits you:

Attachment:
2013-04-18-191115_1024x600_scrot.png
2013-04-18-191115_1024x600_scrot.png [ 104.69 KiB | Viewed 4283 times ]




The results will be saved in a directory called 'output' and consist of both a coloured image and a greyscale image. The coloured looks nice, and the greyscale is for use in openttd.

If you encounter some nice maps/seeds, please share them here with the rest :) Also if you make improvements to the script, I would very much like to see those.

cheers

zooks


edit (09/04/13): added python source
edit (11/04/13): added link to png library
edit (18/04/13): uploaded the gui


Attachments:
File comment: The source code (executable python script + png library)
Depends on pygtk > 2.0

mapgen.tar.gz [180 KiB]
Downloaded 229 times

_________________
My screenshots
A fractal heightmap generator for openttd


Last edited by zooks on Thu Apr 18, 2013 5:28 pm, edited 3 times in total.
Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Thu Jun 21, 2012 8:04 am 
Offline
Tycoon
Tycoon

Joined: Wed Aug 26, 2009 6:33 am
Posts: 2493
Location: Poland
It seems very interesting, what about publishing more heightmaps?

_________________
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Thu Jun 21, 2012 10:38 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Jun 29, 2006 8:36 am
Posts: 259
Here you go, 65 heightmaps (30mb). Takes me around 4 minutes each to make them. I'm still thinking about adding rivers but I'm not sure how to make those look good without making the generation process take too long.

_________________
My screenshots
A fractal heightmap generator for openttd


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Thu Jun 21, 2012 11:23 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Jul 12, 2011 12:09 pm
Posts: 1534
Location: St Ives, Cambs, UK
That is rather cool. :bow: They certainly look better than the standard map generator...would it work for the More Heightlevels patch/ChillPP? Then you could do really huge mountains! :D

_________________
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have a screenshot thread now...
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer buiding robots.
Author of an incredibly boring stickied post about NewGRFs.


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Thu Jun 21, 2012 11:24 am 
Offline
Tycoon
Tycoon

Joined: Tue Mar 14, 2006 12:46 pm
Posts: 1534
Location: Netherlands
any chance you could share sources for the generator?

_________________
Screenshots topic
Scenarios&Heightmaps


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Thu Jun 21, 2012 1:10 pm 
Offline
Director
Director
User avatar

Joined: Tue Aug 17, 2010 10:36 am
Posts: 606
Location: Netherlands
Realy cool, but I think you should get big rivers, (A bit like the rhine donau etc.)

See attached image.

Also I think cities are a bit concentrated too much at the plains. (Or only there). Some small flat low coasts would be great to get some hard to reach coastal villages.

The bottum aprt of that big lake already looks like a river, it reminded me about my holiday at the Mozel.

Edit:
ADVICE TOO ALL!

Go play this maps with you nicest GRF, they are so great. Finnally Make rail building a challange.

(1 small realistic railway line: 26 tunnels, 14 bridges and uncountable corners)


Attachments:
Geen naam, 01-01-1930.png [1.27 MiB]
Downloaded 12 times

_________________
View my (train)pictures on Flickr
Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Fri Jun 22, 2012 7:36 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Jun 29, 2006 8:36 am
Posts: 259
FLHerne wrote:
That is rather cool. :bow: They certainly look better than the standard map generator...would it work for the More Heightlevels patch/ChillPP? Then you could do really huge mountains! :D

With a few modifications it would indeed as it basically translates a 0 to 1 float value to 0 to 15 ints atm, though larger mountain areas are needed to get the higher peaks, maybe in combination with the extra large maps patch as well. If I generate a 256*256 map, mountains will be about half as high as 2048*2048 because there's less space..

ZxBiohazardZx wrote:
any chance you could share sources for the generator?

Sure I will, though preferably not in its current state, I want to make the code a bit more readable before sharing it and maybe add rivers and deal with some oddities. If youre really eager, pm me and Ill send you the source.

jor[D]1 wrote:
Realy cool, but I think you should get big rivers, (A bit like the rhine donau etc.)
See attached image.

The problem with rivers is that it is hard to come up with a set of rules like where they should start and how they should flow etc, if you have some pointers (weblinks) to useful algorithms, let me know :)
PS, did you downscale the map to 1024^2? It looks as if the mountains in the picture are less rough than normal..

jor[D]1 wrote:
Also I think cities are a bit concentrated too much at the plains. (Or only there). Some small flat low coasts would be great to get some hard to reach coastal villages.

I'm not sure why the flat plains are mostly concentrated in the centre, I can try to force the process into more flat land at the coast, but as everything is basically random this is hard. Some maps turn out with great flat coastlines while others have mostly hilly coasts.

jor[D]1 wrote:
Finnally Make rail building a challange.[/b]
(1 small realistic railway line: 26 tunnels, 14 bridges and uncountable corners)

Thanks :), It indeed is more of a challenge to (realistically) find your way through the mountains.

_________________
My screenshots
A fractal heightmap generator for openttd


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Fri Jun 22, 2012 8:31 am 
Offline
Director
Director
User avatar

Joined: Tue Aug 17, 2010 10:36 am
Posts: 606
Location: Netherlands
No, played on 20xx*20xx''

But, i use it with chill patchpack, which uses 256 colors for heightmaps. Maybe that makes them less rough, or it could just be coincidence, some maps had real rough costs with "boulders" in sea.

_________________
View my (train)pictures on Flickr


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Fri Jun 22, 2012 9:39 am 
Offline
Tycoon
Tycoon

Joined: Tue Mar 14, 2006 12:46 pm
Posts: 1534
Location: Netherlands
Mainly wondering because my previous realistic map attempt failed due to a harddrive issue, i am in need of a fast landscape generator that results into realisitc landscapes. i dont care if i have to after-edit it, i just need a plain heightmap that i can fill with rivers, cities, infra etc

similar to cindini, with a change of me not manually scaping the land, for im not that crazy

_________________
Screenshots topic
Scenarios&Heightmaps


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Fri Jun 22, 2012 11:41 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Jun 29, 2006 8:36 am
Posts: 259
jor[D]1 wrote:
No, played on 20xx*20xx''

But, i use it with chill patchpack, which uses 256 colors for heightmaps. Maybe that makes them less rough, or it could just be coincidence, some maps had real rough costs with "boulders" in sea.


Hmm, yeah I see now, the problem is that the heightmaps are in the range of 255 but only define 15 levels in between, also ottd automatically smooths the slopes which makes it look less rough. To get it looking the same with the 256 height levels some things would have to change. I suggest you try it once with only 16 heightlevels, it looks better :)

ZxBiohazardZx wrote:
Mainly wondering because my previous realistic map attempt failed due to a harddrive issue, i am in need of a fast landscape generator that results into realisitc landscapes. i dont care if i have to after-edit it, i just need a plain heightmap that i can fill with rivers, cities, infra etc

similar to cindini, with a change of me not manually scaping the land, for im not that crazy


PM'd you the source ;)

_________________
My screenshots
A fractal heightmap generator for openttd


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Sat Jun 23, 2012 7:34 am 
Offline
Tycoon
Tycoon

Joined: Tue Mar 14, 2006 12:46 pm
Posts: 1534
Location: Netherlands
hmmz i cant get a nice looking 4k*4k out of it, it works ok for the 2k*2k, but on 4k's it isnt popping something i like yet...

_________________
Screenshots topic
Scenarios&Heightmaps


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Wed Aug 08, 2012 2:52 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Jun 29, 2006 8:36 am
Posts: 259
Im in nepal at the moment so lots of inspiration here. When Im back I'll get back on this, and will look how easy it is to adjust for larger mapsizes and more heightlevels. Right now it was really focussed on 2048, and down to 512 it looks fine but outside that range it turns bad indeed. If anyone knows some good information sources on natural map/river/town generation, please share it with me ;)

_________________
My screenshots
A fractal heightmap generator for openttd


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Thu Aug 09, 2012 2:50 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Mar 22, 2012 11:10 am
Posts: 3455
Location: West Java
Sorry to say, but likely the mountains generated are too sharp for OTTD slopes ? Because its a quite large problem when the slopes becomes too much...

Aanyway, maybe some extra large map patches can overcome those...

_________________
Officially "away" somewhere for years !

YNM = yoursNotMine - Don't get it ?


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Thu Nov 08, 2012 4:22 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Jun 29, 2006 8:36 am
Posts: 259
Yoursnotmine wrote:
Sorry to say, but likely the mountains generated are too sharp for OTTD slopes ? Because its a quite large problem when the slopes becomes too much...

Aanyway, maybe some extra large map patches can overcome those...


The generation process is limited to 15 heightlevels and afterwards gets adjusted to openttd slopes so what you see on the previews is pretty much what you get ingame.

A problem though is that there seem to be no parameters that specify things like continent size, number of continents/islands, variety distribution. This is probably because I don't understand the (diamond square) fractal enough.

_________________
My screenshots
A fractal heightmap generator for openttd


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Tue Apr 09, 2013 11:59 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Jun 29, 2006 8:36 am
Posts: 259
Here is the python code (2.7.x). Not documented and not really readable, no guarantees.

Attachment:
mapgen.tar.gz [2.04 KiB]
Downloaded 123 times


The call should look something like this:
Code:
python mapgen.py <width> <height> [seedstart] [seedend] 


width and height can range from 1(128) to 5(2048)
seedstart and seedend are the seeds given to the random generator. If both left empty, the script will produce one random map called test.png

example: to create 100 maps 1024*512, you would use:
Code:
python mapgen.py 4 3 100 200


This results will be saved in a directory called 'output', and you have to create this directory (once) yourself if it is not there.
The results will be both a coloured image and a greyscale image. The coloured looks nice, and the greyscale is to use in openttd.

If you encounter some nice maps, please share them here with the rest :) Also if you make improvements to the script, I would very much like to see those.

cheers

zooks

_________________
My screenshots
A fractal heightmap generator for openttd


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Tue Apr 09, 2013 4:45 pm 
Offline
Engineer
Engineer

Joined: Mon Mar 25, 2013 6:24 pm
Posts: 36
I really don't how i get this working...


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Wed Apr 10, 2013 11:15 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Jun 29, 2006 8:36 am
Posts: 259
MisterX wrote:
I really don't how i get this working...


That's not much of a question, can you tell me what the problem is? What python version are you using? What operating system? I can help you if you're on linux

_________________
My screenshots
A fractal heightmap generator for openttd


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Wed Apr 10, 2013 11:45 am 
Offline
Engineer
Engineer

Joined: Mon Mar 25, 2013 6:24 pm
Posts: 36
I just downloaded python 2.7.4 for this. Have no experience with python, so maybe I do something stupid...
Operation system is Windows 7, not linux.

I googled to found how to run a .py file and found the following:

Quote:
On windows platform, you have 2 choices:

1.
In a command line terminal, type

c:\python23\python xxxx.py

2.
Open the python editor IDLE from the menu, and open xxxx.py, then press F5 to run it.


This help was for python 2.3.x, so i have to change the python23 to python27, i guess and i placed mapgen.py in c:\python23\
Then i tried the first option (ofcourse with mapgen instead of xxxx). But i get 'SyntaxError: invalid syntax' and the : is highlighted in red.
The same happens when i add 4 3 100 200 (the same numbers as in your example) after it. Same error happens....

Thus tried the second option. When I press F5, also a error occurs:
Quote:
Traceback (most recent call last):
File "C:\Python27\mapgen.py", line 5, in <module>
import sys,os,png,random,colorsys,math,time
ImportError: No module named png


So somewhere i do something wrong... Maybe i place the map output at a wrong place? Where must i create that map?

Hope you see my mistake...


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Wed Apr 10, 2013 2:49 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Thu Jun 29, 2006 8:36 am
Posts: 259
MisterX wrote:
Thus tried the second option. When I press F5, also a error occurs:
Quote:
Traceback (most recent call last):
File "C:\Python27\mapgen.py", line 5, in <module>
import sys,os,png,random,colorsys,math,time
ImportError: No module named png


So somewhere i do something wrong... Maybe i place the map output at a wrong place? Where must i create that map?

Hope you see my mistake...


Ah I see now. I totally forgot to mention that it uses the pypng module/library. Apologies

Easy fix: put this file: http://pypng.googlecode.com/svn/trunk/code/png.py
in the same directory as mapgen.py

After that, it should work. Let me know if this helps.

cheers

_________________
My screenshots
A fractal heightmap generator for openttd


Top
   
 Post subject: Re: Fractal heightmaps
PostPosted: Wed Apr 10, 2013 7:11 pm 
Offline
Engineer
Engineer

Joined: Mon Mar 25, 2013 6:24 pm
Posts: 36
Quote:
On windows platform, you have 2 choices:

1.
In a command line terminal, type

c:\python23\python xxxx.py

2.
Open the python editor IDLE from the menu, and open xxxx.py, then press F5 to run it.


1 gives still an error, i think a do still something wrong, but with 2 i can make maps. But then he used the predefined sizes. Standard 256x256, so the first time i tried 2, i get a 256x256 map. But in mapgen.py, i easiely can change the standard, so as second a 2048 x 2048 was made. So i can make some heightmaps with it.

Thanks for this tool, very usefull.

How big could you choose seedstart and seedend? Are there some limits?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 27 posts ]  Go to page 1 2 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.