Generating Provinces From A Map

Started by
10 comments, last by Stainless 7 years, 10 months ago

For the slowness concern; when I write iterative generation algorithms like this, I usually allocate a block of ints twice the size of the map, and re-use it over and over as the process continues, sometimes as a doubly-linked list structure. Before the "grow" step I described, I'd initialize all elements to 0, and all unassigned land adjacent to assigned-province tiles into the list. After changing province assignment of a tile, I'd add all the adjacent, unassigned land to the list. This way, every pass I'm just walking the list of province-bordering tiles, not the entire map. You can tell if a tile is already in the list and doesn't need to be added, because one or both of its pointer indexes will be nonzero. The phase is done when the list is empty.

Once you add the Conquer phase, the blockiness of some provinces will start to disappear, especially if you make your initial seed chunks a little smaller.

RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
Advertisement

Once you have a system you like, move it to a shader.

This sort of technique can become really fast once you do.

One other thought.

I would test out a system similar to Conway's game of life. Calculate a value for a pixel based on the content of it's neighbors and use that as a decision variable,

So if a pixel is unassigned, go around it's neighbors. If you have 3 from province A and 2 from province B you can then set a rule to decide the value.

I would simply build a probability table based on the neighbors count. 2 A, 2 B, 1 C gives you a 40% chance it is A, a 40 % chance it is B and a 20% chance it is C.

Since you do this on a per unassigned pixel basis, it should grow quickly without giving you the blockiness ( as long as you have a decent random number :D )

This topic is closed to new replies.

Advertisement