Realms Beyond Forum

Full Version: Mirrorland, the fairest map script of them all
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
You guys know I like maps, right?

Well I decided to tackle writing a script that does fair maps well. Here's v1. It spits out maps like the one I made for pbem32 in just a few seconds. It scales to any number of players (though keep in mind that past 5, you can't have everyone equidistant from everyone else). I honestly think it could be used directly to generate a solid map with no human intervention (making it usable for live MP games if desired), though light editing rarely hurts a map.

Here's a sample map I just rolled (1st try):
[Image: mirrorland_8.jpg?raw=1]
The script will make sure every capital has at least 2 food tiles, at least one of which is a grain, AH resource, or deer. It also gives everyone a minimum of 3 hills and 4 forests. Starts are almost always near a river as the capital spot selection knows this to be valuable.

[Image: mirrorland_6.jpg?raw=1]
Bodies of water tend to be snaky. The majority will have at least 20 water tiles so boats are buildable, but it's not guaranteed. (Most aspects of the map generation are probabilistic.) On this map, you can see the whale lake is not fit for boat building. You can, of course, use canals to reach it from the other two seas on the map.

[Image: mirrorland_7.jpg?raw=1]
Here's a wide shot so you can see the seamless mirroring. The map generation is built on top of a spatial model that doesn't have edges, so there are never artifacts.

Here's another one:
[Image: mirrorland_5.jpg?raw=1]
This time I turned on "Critical resources close", which is a bit like the Balanced Resources option you find on some maps. Of course a totally mirrored map is balanced by definition... but this option ensures that everyone has at least one horse, copper, iron, and land-based oil that's at least twice as close to them as to anyone else, so that it's much harder to be stuck without the necessary resource to build an army to claim said contested resource.

Note that the military strategic resources are all guaranteed to appear. However, stone and marble (along with every other resource) are not. For those I use the official Civ IV formula, which is based on suitable tile count, player count, resource-specific numbers and some randomness. Due to each resource needing to appear at least N times or not at all which is quite a jump, if a resource doesn't make it I carry over the remainder to the next resource to place. (E.g. in a 5-player game, if I'm supposed to place 4 ivory and then 3 dyes, 0 ivory will be placed, but the 4 will carry over to make 7 dyes; I place 5 of them and 2 carry over, etc.) Resource placement happens in category order (strategic, marble/stone, food, luxes, sea) so the carryover will typically apply to a similar kind of resource. So you'll get a reasonable number of luxuries, but probably not every type in a given game.

[Image: mirrorland_4.jpg?raw=1]
You can see the script will sometimes generate islands. The last one had none, but this one has 2 per player.

Here's a 2-player map.
[Image: mirrorland_3.jpg?raw=1]
Even though it's much smaller, the terrain largely has the same qualities. This is because if you factor out the duplication of N copies, a similar number of tiles are generated with each player count (about 300).

Here I have the screen centered on quite a few oddly-placed resources. Plains incense, forest gold/pigs/silver/dyes/wine, and jungle corn are not really "natural". Mirrorland follows these rules only probabilistically, though. Corn has a much lower chance of spawning on a jungle, as well as on a non-grassland, but still some small chance. (Btw, did you know that a whole host of resources, including all grains, livestock, copper and iron, are never supposed to be next to a river? Due to some edge cases in the normal map generation code which I'm not sure are intentional though, this is ignored in many cases. Mirrorland just assesses an odds penalty - they usually won't spawn riverside, but sometimes will.)

(P.S. After rolling this map, which had a fairly high proportion of oddly-placed resources, I decided to reduce the chance of resources spawning on forests/jungles they don't normally spawn on a bit. I don't mean for things to be that crazy.)

It goes all the way up to 18, by the way. Here's an 11-player map:
[Image: mirrorland_2.jpg?raw=1]

There are also several options for water. Here's "Inland Seas":
[Image: mirrorland_1.jpg?raw=1]
Water level is the same - still just below the threshold for enabling circumnavigation, but the seas are more coherent and much less snaky.

The full list of water options is:
Lakes (0.5x water)
Waterways (default)
Inland Seas
Inland Oceans (1.5x water)
Flooded Waterways (2x water)

Lakes has limited or no boatable seas; it's basically a land map. The two styles with increased water are kind of like their counterparts, but are heavy water maps. Circumnavigation will be available, and Flooded Waterways verges on being an archipelago.

I plan to add two more options:
1) Preplaced improvements, rather like pbem32. [Edit: this is done now in v1.1]
2) Various levels of permutations, by which I mean breaks from complete symmetry.

If there are any requests for other options, please ask. Other layouts (including mirroring and rotation) should be fairly easy to add as long as they are toroidal.

Btw, I ran into some strange crap while writing this script. One small mathematical error and everything goes to hell. Observe:
[Image: mirrorland_9.jpg?raw=1]

>>> Download Here (v1.1) <<<

Comments, questions, and suggestions are welcome. smile

P.S. Note to people who are actually going to look at the code - I am sincerely sorry about the variable names. I realized different things were pertinent at different times, and never went back and renamed things.
Awesome! I will try this out this weekend.
I want to play on the last map - look at all that aluminum smile
That's really quite impressive thumbsup

SevenSpirits Wrote:If there are any requests for other options, please ask. Other layouts (including mirroring and rotation) should be fairly easy to add as long as they are toroidal.

FFH support?

I'm not actually sure where the boundary is between the script and the mod, given that things like Inland Sea work just fine in FFH. But maybe that's because the FFH creators modified the mapscripts to support FFH resources?
Mardoc Wrote:FFH support?

I'm not actually sure where the boundary is between the script and the mod, given that things like Inland Sea work just fine in FFH. But maybe that's because the FFH creators modified the mapscripts to support FFH resources?

That would require a decent amount of manual editing by someone who knows FFH. I hardcoded most of the terrain types/etc because I had to rewrite basically everything, and it's a lot of extra work to make it work for arbitrary mods.
SevenSpirits Wrote:That would require a decent amount of manual editing by someone who knows FFH. I hardcoded most of the terrain types/etc because I had to rewrite basically everything, and it's a lot of extra work to make it work for arbitrary mods.

That's unfortunate.
Pah, way to not come up with this before we started 38. tongue

So is plains cow counted as an "AH food resource"? I would not count it...or plains hill sheep for that matter.
NobleHelium Wrote:Pah, way to not come up with this before we started 38. tongue

So is plains cow counted as an "AH food resource"? I would not count it...or plains hill sheep for that matter.

You didn't want a mirrored map for 38 anyway, right?

Yes, it is. And I realize that's a bit sketchy. I may refine it. For now I've yet to see a start with not enough food, so I've left it as is.
I did want a mirrored map if it was an option. We just didn't have anyone to make it. I specifically said "something like 32 would be good."

Is this supposed to only generate normally valid tile combinations? I assume jungled and forested oil does not normally occur.
Wow, that's awesome!
Pages: 1 2 3 4 5