Map Generator for Terraform

hannurabi

Warlord
Joined
Aug 29, 2005
Messages
173
This is simple Random Map Generator for Terraform's Read Map Gen feature.
I made it in just couple of hours so it certainly isn't too great. Maps it generates aren't same level with Civ's own map generator but they can be interesting for trying out something different.

Usage: Extract all files in same directory, e.g. c:\program files\Terraform
Run Mapgen.exe, open terraform ,load saved game, choose Read Map Gen --> Map.txt

Hopefully I manage to write more interesting Map Generator in the future.


updated
 

Attachments

  • Mapgen2.zip
    347.6 KB · Views: 252
Very nice!


Assume columns X goes from 0 to 79 - rows Y 0 to 49

In maps generated by CIV, always have oceans in columns 78 79 00 01 02

Rows 0, 49 are always artic or tundra
Rows 1 and 48 are always ocean, artic or tundra.
Rows 2 and 47 are always ocean.

CIV is not equipped to deal with cities that control squares that extend over the edge boundaries.

My tests have shown the land in column 2 is acceptable
Also making rows 01 & 48 ocean you can use rows 02 & 47 for land.
 



The game cannot handle cities whose area of control (the 21 squares that make up a cities area) hangs over the zero longitude on the world map . Given this restriction no land square that the game uses to build cities on (river, plain, grassland) should be closer than 2 squares from the zero longitude.
The game itself will not allow one to build cities in the Artic and Antarctic. So one could produce a map that uses any type of terrain in rows 0, 1, 48 and 49.

See the above image for five city views showing various cities near the zero longitude seam.
Left to right:
1 & 2 show a city on column 78 and one on column 79. Both of these are problematic in that there area of control overhangs the seam.
3 & 4 show a city on column 0 and one on column 1. These seem to function ok but loose access to the squares that overhang. I would advise further testing to be sure that there isn’t some other problem with this city placement
4 shows a city on column 2 which appears normal.


All test were with version .05
 

Attachments

  • column.png
    column.png
    17.9 KB · Views: 1,889
Ok, I updated the map generator a little. Now columns 78,79,0,1,2 are always ocean.
Rows 0 and 49 are arctic, rows 1 and 48 ocean or tundra and rows 2 and 47 are ocean.
Maps it generates, have pretty sneaky continents and islands, see screenshots.
My next goal is to get away from too much sneakiness and maybe give user more control of generation, to choose to have pangaea/islands/continents/sahara etc. different map styles.
 

Attachments

  • TFmap1.PNG
    TFmap1.PNG
    169.3 KB · Views: 279
  • TFmap2.PNG
    TFmap2.PNG
    198.2 KB · Views: 346
  • TFmap3.PNG
    TFmap3.PNG
    188.2 KB · Views: 206
  • TFmap4.PNG
    TFmap4.PNG
    228.1 KB · Views: 249
  • TFmap5.PNG
    TFmap5.PNG
    168.4 KB · Views: 268
I started writing a map generator several months ago. Unlike me, it looks like you may be determined to release one, :) so I'll tell you what I learned.

I spent almost all my time on continent generation, and I found a good way to do it. To start, you need to divide the entire map into "plates." I found the best results when I set the map to wrap around both east-to-west and north-to-south. To make the plates, first you put "seeds" at random spots on the map, ideally 100-150 of them. Every seed is in a list, and you expand the plates by taking one seed at random from the list. When the seed is picked, that tile becomes part of a plate, and every adjacent tile that's not already part of a plate is added to the seed list, while the seed just taken is removed.

Each seed lists all the plates it can be added to, in case there are several. In that case, the plate it attaches to is chosen at random.

Once the map is fully divided into plates, you can decide, for each plate, whether it will be continent or ocean. First of all, take all the plates with even one tile on a "forbidden" latitude or longitude and turn them into ocean. After that, you can have fun with it. The easiest way is to turn plates into ocean in random order until there are about 1200 (or some other number) tiles left, and leave those as continent. Another way I like is to make the 30th longitude "forbidden," which makes a somewhat Earth-like map, with two main continent groups, and then trim plates as before until you reach a target number of continent tiles.

Ask for clarification if you need it. I may be able to come up with some simplified examples.

Here are some pictures. The polar continents are added with an algorithm so trivial it's hardly worth mentioning (ever thought about using latitudes 1 and 48 as Morse code?). These maps all use 120 plates, have a forbidden 30th longitude, and target 1200 tiles of non-polar continent.

You can configure the continents in the obvious ways by choosing continent/ocean in a different way, or targeting a different number of continent tiles. The really interesting way is to change the number of plates. More plates will give you a stringier, more random map. Fewer plates will give you a blockier map, with some tiles far away from an ocean.

Best of luck!
 

Attachments

  • terrain3.png
    terrain3.png
    3.5 KB · Views: 150
  • terrain2.png
    terrain2.png
    3.5 KB · Views: 159
  • terrain1.png
    terrain1.png
    3.5 KB · Views: 155
hannurabi, I am impressed with the natural development of rivers. Of the two illegal land forms I’ve not seen an instance of a one square river leading no where.

The other illegal land form; (patterns never produced by the game) ocean squares that are connected at 45 degrees only, are quite numerous.

____​

From TerraForm post 91

1)Rivers that are only one square that do not connect to the sea. The game seems to be ok with this, but does not display a river square with a stream, only a bare river square. Look at the center square in the 3x3 island. It is a river.

2) The three 2X2 land squares connected by land bridges have strange attributes. Boats can pass through the land bridge connecting the 2x2 squares. Also land units can cross the bridges connecting the 2x2 squares. This never appears in worlds created by the game.


 
Dack, while I agree I've never seen the Civ 1's random map generator make that diagonal landform, I wouldn't call it illegal, both because in small amounts it doesn't affect gameplay negatively, and it's present three times on the official Earth map, in north Russia. I will agree, however, that gameplay is affected significantly if it's used too much.

My continent generation algorithm makes this coastline occasionally, especially if the number of plates is high. I've played with changing the definition of "adjacent" to a king's move, rather than vertical and horizontal, during plate generation, which makes it happen all over. This could be used as a configuration option.
 
Urtica dioica

As I was typing post #6 I knew that I should have put an asterisk with a foot note.

You said: "in small amounts it doesn't affect gameplay negatively"
“small amounts” is the key word. Perhaps you should produce a world littered with terrain of this type to see if it does affect movement of the games countries vessels.

You said: "it's present three times on the official Earth map"
Yes there are three occurrences on the earth map, but this is a hand drawn map not produced by the game.


Illegal may or may not be the best description, perhaps non-standard CIV attribute. The problem with non-standard CIV attributes is when one adds them to the game the ability of CIV to deal with them is unknown.
 
Urtica: Your continent generation method sounds interesting and looks to result nicely shaped continents too. I'm willig to try it out but I think I'm need for some more clarification. If you could give me small example code how to expand the plates. If I understood right 120 plates are generated from 120 starting seeds but then I came to trouble how to expand the plates.I need to make a list for every seed to which plates it can be added, is this correct?.

I agree my map generator creates too much 'illegal terrain'.It's easy fix and the final version will have much less of it.
 
Here's my first finished random map generator. Unfortunately, it's in Python, and since I'm Windows-stupid, I didn't make an EXE. You can always install Python 2.6 yourself if you don't have it.

This makes some pretty good maps, even though the code needs some clean-up. It's quite configurable, but right now you have to edit the source to access the configuration options (and figure out how it works, without many comments). Sometime soon I'll set up a public repository, and just link to that, so I don't have to re-upload every new version.

I haven't made this very easy to run... sorry about that. But if you manage to run it, let me know what you think. :)

Edit:

I've played with my maps in TerraForm now, so now I can post some actual pictures. In the process, I can explain what sort of configurability I've got.

Each image is made with my current defaults for map generation.

First, the canvas is divided into 120 plates. With a higher number, the continents become more stringy and random, while a smaller number makes blockier landforms.

Every plate that straddles a certain line of longitude is turned into ocean. This is definitely not required, but tends to make a notable division between a new world and an old world.

More plates are removed, until about 1200 non-polar land squares remain. The Earth map uses about 1500 instead. It's easy enough to change it to whatever you want.

The land area is divided into separate habitats, which will later be filled with one or more of the 10 dry biomes. A number between 0 and 1 is used to govern, in general, how big each habitat is, with the current default at 0.3. With this number set to 0, one type of terrain will stretch across huge swaths of terrain, while if it's set to 1, two adjacent tiles can only match by chance.

These maps were designed to have about 100 river tiles each, which can be changed. The typical lengths of individual rivers could potentially be changed, but I'd have to add code for that.

Each of the habitats are filled in with a biome, chosen with a random distribution governed by a string, currently "ggggggpppppfff000012". The letters correspond directly to their biomes. The numbers can be used a couple different ways. In one case, they can represent a choice of biomes; when "2" is selected, that region will be filled with each tile randomly chosen from "mhh". This helps mountains and hills to occur in the same area, creating interesting mountain ranges. In the other, more complicated case, a series of distributions correspond to latitude. For instance, the number "0" can make arctic and tundra near the poles, and desert toward the equator. Similarly, "1" can make swamp toward the poles, and jungle toward the equator.

Of course, I need a better way of exposing this configurability than editing the source code. Making command line options will be a high priority. A GUI (and a Windows binary :blush:) would also help make it easier to configure. The source is available, so if anyone wants to help...

Edit 2:

The observant may note the presence of diagonal land/ocean formations in the 4th sample map. This can happen when a "four corners" (Utah, Colorado, New Mexico, Arizona) formation shows up during plate formation. It's not too common, and I kinda like it, but maybe others won't. Go ahead and flame me. ;)
 

Attachments

  • plates.zip
    1.9 KB · Views: 137
  • 1.png
    1.png
    246.4 KB · Views: 285
  • 2.png
    2.png
    242 KB · Views: 173
  • 3.png
    3.png
    250.8 KB · Views: 280
  • 4.png
    4.png
    255.3 KB · Views: 218
I really like your map generator Urtica. Especially the continent generation method.It really creates nice,organic and realistic looking shapes.Rivers also flow beautifully.I gotta say I'm impressed.Some flaming too: I think there's too few hills and mountains as default.Of course the source is there and I shoud be able to change it more to my liking.And the AI propably plays flat maps better too.
Of course, I need a better way of exposing this configurability than editing the source code. Making command line options will be a high priority. A GUI (and a Windows binary :blush:) would also help make it easier to configure. The source is available, so if anyone wants to help...
It's funny you post this here now as I'm currently improving my map generator as a small school project.I'm going to build a GUI/editor too and I'll propably use Python too.So, if you don't mind I could add your generator also to my little GUI.(Of course I wouldn't take credit from your generator to myself, I would tell my teacher where I got it from.)
My Map Generator in the first post of this thread was Python code too and I converted it to C code using some program I have forgotted the name and then compiled it to EXE.Do some googling and you should soon have Windows binary if you want.
 
Urtica dioica, Stinging Nettle, I am intrigued by your map generation program, very nice indeed!




I offer the following three as suggested parameters for map making programs

Arctic rows
A) Standard 0 Land / 1 mixed land and sea / 2 Ocean (tundra & artic)
B) 0 Land / 1 Ocean (tundra & artic)
C) 0 and 1 Ocean
D) No Ocean but 0 and 1 must be terrain that cities the game does not build on (e.g. mountain, artic, desert)

Antarctic rows
A) Standard 47 sea / 48 mix / 49 Land
B) 49 Land /48 Ocean
C) 48 and 49 Ocean
D) No Ocean but 48-49 must be terrain that cities the game does not build on

Column Zero Seam
A) Standard columns 78, 79, 0, 1, 2 ocean
B) Min Ocean 78, 79, 0, 1 ocean


Also perhaps some way of controlling the ratio of terrain types.

One other thought the special resource squares could be enhanced. A simple formula can determine if a square is a special resource square. One of the options of the map generating program could determine the randomness value of each type of square. Assigning the type desired by the used. If either of you, hannurabi or Urtica dioica, have in interest in perusing pursuing this I would certainly be willing to alter the Read Map Gen feature to include a way of assigning the special resource square value to the SVE file.

Very creative, can’t wait to see more.
 
I always did assume that Terraform already includes a random map generator?

But this sounds great:
generate random maps, love a result from it
and alter this with terraform to f.e. a new scenario, very helpful. :)
 
Hi!
Another random map generator for Dack's TerraForm (File/Read Map Gen/map.txt)
Pro+
>.exe >pole&date line protection (arctic,ocean,desert) > large chance to be 0 out of 7 city in ocean (93,2%) so easy to import and save: you will not know, where are the other civilizations : more random >more villages >plains are able to the most advance: irrigate+road=large city, forest=shields
Contra-
>NO CONTINENTS AT ALL only plains (1% ocean, i mean lake for irrigation) >ugly rectangular design >may boring that no other type of terrarians
 

Attachments

  • CIVMX001.ZIP
    2.5 KB · Views: 115
@martx
Hmmm... Does that program always creates the same map? Or maybe I don't know how to use it.
However the idea of great plains map is nice,I might try to play that map sometime.
 
Because of this new thread, I've decided to release an update to my map generator. I actually had this ready ages ago, but didn't release because I wanted to address the configuration and Windows binary issues. Then I stopped. So, the big problems aren't fixed. But it does feature at least one bug fix, a significant speed-up (not that it was that slow before), a license (it's open source; you can do anything you want with it) and a major code clean-up. The clean-up is a big deal, since without a binary or an easy-to-use configuration system, it's not much good to non-coders anyway. By reading and editing the source though, it's really quite configurable, and I hope you'll figure out how it works. :)

@hannurabi: I should have answered you sooner - sorry about that. Don't know if you still care about this, or if you used my generator anyway, without permission. You can do whatever you want now, and legally too!
 

Attachments

  • map.zip
    2.9 KB · Views: 146
...MAP.ZIP...

Code:
C:\Python31>python plates.py
  File "plates.py", line 50
    self.exclude = [(lat,long) for lat in 2,LATS[-3] for long in LONGS]
                                           ^
SyntaxError: invalid syntax

C:\Python31>

The above is what I see after running plates.py in Python31. I have no familiarity with python so the problem could well be me. Did I miss something?


Edit Nov 06, 2010 at 16:54 GMT : I went back to Python27 and had success. I assume that the Python developers don’t believe in forward compatibility.

Added Nov 06, 2010 at 17:57 GMT : Using your map generation program I produced six maps. Truly works of art. Have you thought of some parameter control? Perhaps; the percentage of each type of terrain., the number of Islands. Are you going to continue work on this? I for one would offer encouragement
 
Python 3 was never meant to be compatible with Python 2 from the start. I'd be shocked if it didn't fail at a bunch of other points too.

Thanks to your flattery, Dack, maybe I will continue working on this. The biggest issue I ran into before was how to expose all the configurability to the user. It's become clear to me now, since it's designed to work with TerraForm, it needs to behave like a good Windows program, so it needs to use a GUI. The problem is I'm a Unix command line guru. This will be new to me.

In the mean time (assuming I actually get something done), I can show you how to edit the source to make some more interesting maps. It might be fun. :) Everything you need is under "class Config:", in the __init__ function.

Code:
self.plates = 120

This totally changes the character of the landforms. High numbers result in a greater number of stringier continents. Lower numbers make a few blocky continents.

Code:
self.len_continental = 1200

Simply changes the total number of continental tiles. Make a Pangea or an ocean world, or something in between. There's no way right now to set the number of continents, but with a combination of len_continental and plates, you can do something close.

Code:
self.rivers = 100

Sets the number of river tiles. This is done totally separate from the other terrain types.

Code:
self.biome_size = 0.3

It's a bit tricky how this works, but it affects the size of a bit of terrain. There's even a comment to tell you how to use it. There should be more of those. Then I wouldn't have to explain this in a forum post. Oh well.

biome_dist determines the ratios of different terrains that show up on landforms, other than rivers. As an example, setting biome_dist to 'ggp' would make a world with only grasslands and plains, with grassland 2x more common.

biome_var works with biome_dist in a couple different ways to make "compound terrains". The simpler way: the '+' in biome_dist works as a highland terrain. Under '+' in biome_var, this terrain is divided into mountains and hills, with hills 2x more common. The other way is just my method of dividing terrain based on latitude, and it's a bit more complex. It's got 25 fields, one for each latitude, pole to equator. The '-' or "deserted" terrain keeps arctic and tundra near the poles, and desert around the equator, while the '*' or "overgrowth" terrain keeps jungle around the equator and puts swamp everywhere else.

So, in short response to hannurabi's complaint about too few mountains, just stick an extra '+' in biome_var. :) Maybe soon there will be a friendlier way to do this, I hope.
 
Top Bottom