• Advertisement
Sign in to follow this  

Generating territories (Like in Empire Earth 2) on a 2D-map with different terrain

This topic is 4424 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, as you see I'm new to this forum. I've been programming Delphi for about 8 years, but I'm still learning many new things... I use PHP for my homepage (which is temporarily down due to a Linuxworm), and I also understand a bit C/C++. So, now to the question. I'm working on a Turnbased Strategy game. In this game, I have a 2-dimensional array of different terraintypes (defined as an integer), out of this array I want to create another array containing the 'zone'/territory that the specific map area belongs to. Currently, I have 3 different terraintypes, they are: Land, Water, Shallow (both Land and Water units can travel on Shallow, but no buildings may be built). The current mapsize is 32x32, but I will probably enlarge it to 64x64 or even 128x128 later, when I got the computer AI up and running and add more players (currently it's only 3, but I'm planning for 8). I have some ideas for how to implement these zone generations, but I haven't put it to life yet. - Option: Minimum Zone size constant (defining the smallest size of a zone) - Option: Number of Zones to generate (Minimum-Maximum) - Check number of different areas grouped together (floodcount) - Create lines between one areagroup edge and another, max 2 lines from each area, find shortest line to nearest areagroup of the same type. Seperate the two sides of the line into different territories. - If areagroup isn't big enough (Minimum zone size constant) then count that areagroup (or parts of it) as another areagroup type. (For example, imagine a small island - 10 map areas - surrounded by water, if the minimum zone size constant is more than 10 then this small island will be in the same areagroup as the water). Do you have any ideas about how I can put this into life? Any code examples will be very appreciated. (Delphi is preferred but C code is also accepted). I think my biggest problem with implementing my idea/ideas is within "Create lines between one areagroup edge and another", how to find those edges? And how to know where to draw the line? And what to do if the complete map is just plain Land? Hope you can help, Thanks for your time, Simon from Sweden

Share this post


Link to post
Share on other sites
Advertisement
That sounds to me like random labyrinth generation in Angband and etc.
You could take a look at it, since Angband and its clones are opensource and easily found on the web.

You also may try looking at Joshua's articles.

Hope that helps.

[Edited by - Archi on January 5, 2006 8:04:27 PM]

Share this post


Link to post
Share on other sites
I don't think those articles helped me much, although I haven't read through them completely, it doesn't seem like that's what I'm looking for.

Take a look at this map: http://www.zomis.net/temp/2.jpg

Now I want to divide this map into several territory zones.
So, it would be oubvious that the lower-left island (green), including the shallow water (light green), would become one zone/territory.
And then, the lower right island (including some "road" - the part on the island which isn't green) would also become one zone/territory, however, since this island has some shallow water leading to the central island, the zone/territory must be divided somewhere there between.
The central island also forms one zone/territory, but the upper-right part of the island should become a territory in itself, otherwise the territory would be too big.
And last, but not least, the water should be divided in 3-4 territories (one on the right side of the map between those shallow parts, the rest splitted up in some way).

The big problem for me is: How to find/create a good algorithm which divides these territories marking all small tiles with a territory-number?

Share this post


Link to post
Share on other sites
Should be working, so sorry if the post is a little concise.

Why don't you work in reverse, and establish a number of bounding circles equal to the number of zones you want, of various sizes. Generate shallows inside first, then generate land inside the shallows, and last generate the road.

Simply provide a percentage for each with a chance of variation - e.g. shallow fills 90% of the circle, with a 5% variation. Land fills 80% of the shallows with 10% variation. Etc.

For larger islands, overlap some of the circles and join them up. Just remember that road always overlaps land, which always overlaps shallow, so you don't have to worry about shallows from one circle going over land of another.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement