# Map Generation

Discussion in 'Civ1 - General Discussions' started by gladoscc, Aug 8, 2011.

Joined:
Aug 5, 2011
Messages:
125
What I have so far (for a single continent): http://glados.cc/TerrainForm.swf
Arrow keys to move, space to generate new map.

My horrible algorithm:

For every possible neighbor (up,left,down,right) of a existing tile, it has a chance (starts at 95%, goes down by 0.5% every tile generated) to become a new tile, and the cycle repeats.

Are there better algorithms?

2. ### InnateGamerEmperor+2

Joined:
Jul 30, 2011
Messages:
48
What a coincidence, I'm working on this same exact problem myself. Yes, there's a slight modification to what you're doing that makes it a better algorithm, use some information in the neighbourhood to change the probability of creating land, like lets say the square has several neighbors that are also land, then either increase the probability of generating land to get a smoother coastline, or decrease if you want a checkered coast line and lots of tiny lakes. Or you can choose a larger neighborhood too. Or you can use the number of nearby land squares belonging to a different continent to change the probability of growing land, increase probability to cause continents to grow together, or decrease them to make the stay apart. After initial growing of the continents you can add more passes, like dithering or filling passes, if you want to make the coastline smooth a dithering pass could remove all squares that have less than x neighboors that are land, for instance. Then after you've created land you can grow other types of terrain on the land, like create small "continents" of forest on the land, and so forth.

I just clicked on your link once more, to generate a few maps, and although I havn't finished my map generator yet I see that your coast line is rather checkered and there are lakes and such, if you want to remove these all you'd have to do, I think, is to increase the likelyhood of growing land if there are several neighbors that are also land. Damn, I think I've managed to spell the word enighbor in every conceivable way, anyway, there's an awesome article/blog/chat whatever on the internet about this very subject, reading that is where I think I learned about how terrain generators work, I'll try to find the link but it was a long time since I read it.

Joined:
Jul 30, 2011
Messages:
48

Joined:
May 8, 2008
Messages:
76

Joined:
Aug 5, 2011
Messages:
125
6. ### InnateGamerEmperor+2

Joined:
Jul 30, 2011
Messages:
48
I have tried the algorithm I mentioned earlier, and I've so far failed to produce interesting looking results. I'll have to try to find a new algorithm.

7. ### Urtica dioicaChieftain

Joined:
May 8, 2008
Messages:
76
When I tried the app on your blog, the continents seemed... round. Consistently uninteresting/predictable coastlines probably means you're using a different seed expansion algorithm.

Another problem is world edges. When you place continent seeds on an ocean background, then expand the continent seeds, they're going to squish flat against the edges of the map. That's fine for lots of games, but the idea of Civ is usually that you're playing on a world map. One solution is to make your adjacent tile function wrap around to the opposite edge. That's a bad solution for Civ 1, because of the way it handles cities next to the meridian, but for a less limited Civ game it might be OK.

My solution was to do away with continent seeds, and start with plate seeds. You divide the entire map into some number of plates, then make every plate either continent or ocean. For Civ 1, you make every plate that's on a forbidden longitude/latitude ocean, then maybe flip interior plates at random until you have the number of continental tiles you want. You can see some pictures of how one configuration turned out in the earlier thread. I'm very satisfied with it.

8. ### InnateGamerEmperor+2

Joined:
Jul 30, 2011
Messages:
48
You have to tweak some of the parameters to get different looking continents, anyway I agree that the continents didn't look any good, that's why I'm going to try something different. I've read the other thread you mention and you're algorithm seems promising, some very nice results, although there doesn't seem to be a lot of open sea, I like the open sea, like the pacific ocean. Anyway, I might try out your algorithm, but first I'm going to try some algorithm that is based on a height field, that way figuring out which terrain should be hills/mountains wouldn't be very hard. I'm going to try to make a height field map, and then somehow simulate a climate, perhaps there is precipitation in some areas, water runs to lower terrain and if there is enough water there will be rivers, swamps if the water runs slowly and so forth. I don't know yet, I just got the idea yesterday. Basically I'm going to study how the weather on earth works, and then try to simplify that into a system that can work out nice results on a tile based map. You're right about that I should wrap the world around, actually I completely forgot about that the world should be wrapping around, I'll fix that and a lot of other issues.

9. ### hannurabiChieftain

Joined:
Aug 29, 2005
Messages:
173
I think you shouldn't use too much time for map generation this early.There already exists good open source map generators in the web,even Urtica dioica has done one. I mean random maps are nice and so, but it's more important to get game up and running.You need to get into point where you can really start developing AI. Any decent or even not so decent programmer can get the game to that far.(Depending how manageable source code you want to produce). But AI is the obstacle. It requires thinking and maybe some creativity too. And you need to be tenacious too. Sooner or later you will face the wall of geting bored (after all it's just 'stupid' game) no matter how passionate you are.I have learned that.For example Freeciv and Freecol has been years of team work. After all I really hope you can pull this out. But it takes lot of work. Best of luck!

10. ### InnateGamerEmperor+2

Joined:
Jul 30, 2011
Messages:
48
I guess you're right, I could always revisit terrain generation later. But I will at some point sooner or later try to make a nice terrain generation algorithm, I've had this idea to use plate tectonics for terrain generation. And then emulate some kind of weather. When I was thinking about that a thought dawned on me, the terrain that we find natural is in fact not, but rather the result of millennia of civilization. Originally there was more forest on earth, and not that much plains/grassland or other open terrain. The only open terrain there was was either the arctic or desert or some other area where trees simply could not grow. So a totally realistic terrain generator would be a detraction. Most terrain generators I've seen out there havn't been able to produce mountain ranges, but then again I'm still not sure we want mountain ranges. Maybe hand made maps is the best indicator we have of "ideal" terrain.

Today I'm going to start clean my code up a little bit, just to make it easier to work with. My terrain generator didn't work that well, maybe I should give it another try, I don't know. Anyway, this project will take a lot more time than I thought it would, so I better be tenacious, that was a new word for me. Anyway, I don't think there's any chance I'll quit, because there are a few projects that I want to do after this. First I'm doing a civ like game, then a warlords like game, then a turn based strategy without individual tiles and then I'd hope to do a real time strategy. I'll do the first two myself as a learning experience, and boy, am I learning or what? I never thought game development would be that hard. To be honest I got somewhat dismayed by the sheer amount of work that I just played some colonization for a while and did some other stuff, just kinda have fun you know, but I realize now that that isn't going to finish this project. By the way I'm not going to try to make a colonization like game with better AI, because the game of colonization is so complicated due to the fact that almost everything can be captured and because the stack of doom strategy. Colonization could have been the first one of Sid Meier's games that featured the stack of doom. I just want everyone to know that I have not abandoned the project, even if it's going really slowly. Perhaps if I applied myself it would go faster, there's a novel thought, we'll see how fast it goes.

Joined:
Aug 5, 2011
Messages:
125
Don't give up!

12. ### InnateGamerEmperor+2

Joined:
Jul 30, 2011
Messages:
48
Thanks for the support, I needed it.