Are you, in fact, a pregnant lady who lives in the apartment next door to Superdeath's parents? - Commodore

Create an account  

 
Civ 6 Map Scripts

I've been exploring the built-in map scripts trying to understand how they work and how they could be tweaked. Here's what I found so far:
  • Terrain generation is split into two distinct phases ... (1) plot generation, followed by (2) terrain assignment.
  • Plots are essentially elevation, with [OCEAN, LAND, HILL, MOUNTAIN] types. At the plot level, there is no distinction between OCEAN and COAST.
  • Terrain is the specific terrain that we see in game (e.g. PLAINS, or TUNDRA, or TUNDRA_HILL).
  • Each script has variations on how the assignments are made, but a plot set is always generated first, followed by terrain assignment, followed by everything else. In fact, as far as I can tell, the difference between the map scripts I think is solely attributed to the Plot generation phase. Everything after the plot generation including terrain, resources, features, rivers, etc. are generated using cookie-cutter scripts located in the Maps > Utility folder.
In both the PBEM 4 and PBEM 5 maps that I set up, my primary goal was to get a big-picture balance with roughly even amount of land per player, and roughly even distribution across the map. Based on the above, this big-picture land distribution is entirely encompassed in the plot generation phase. As such my hypothesis was that it should be relatively easy to pick out an existing script, hijack the plot generation to a more balanced algorithm, and leave everything else alone as pre-programmed. This would at least reduce the necessary re-rolls from the order of dozens  down to just a couple attempts.

I had a successful proof-of-concept for the plot-generation-hijacking which I will put in a following post. I have taken a cursory look at the starting location generator, however that file is 2200 lines long compared to 200 - 500 for the map script files so I haven't yet unraveled it's mysteries.
Reply

If it helps for additional examples, here's the files for a Azimuthal projection map script that's been posted to the workshop.

Map Script Files

I haven't delved into what's needed for creating map scripts personally yet. lol


EDIT: Also there's a new Terra Map Script on CFC as well for reference.
Reply

PROOF-OF-CONCEPT: Manipulating plot generation only on existing map script
Chosen base script: Pangea

Each of the scripts has a unique methodology for generating the map plots. After browsing the default map scripts, I chose the Pangea as the basis for my experiment because it further broke the plot generation down into two sub-phases, (1) LAND vs. OCEAN, and (2) converting some of the land to hills. One of the utility files is called MountainCliffs.lua which contains a function call ApplyTectonics which takes a given LAND/OCEAN plot as an input and adds HILLS and MOUNTAINS. Some of the scripts appeared to have their own internal hill/mountain assignment rather than using the cookie-cutter function. However the Pangea plot generation algorithm only distinguished LAND vs. OCEAN and then fed this through the utility function to raise some of the land into hills and mountains.

After identifying the above, my task was clarified as coming up with an algorithm to create an even distribution of land vs water. I started by first confirming that I could in fact successfully get a map to generate after editing the Pangea script. I started with a simple 50/50 split of land vs. water, which worked! All other utility functions including hills/mountains, terrain, rivers, resources, features, start positions, etc. all generated properly (except of course for the city states, which were already known buggy in the WorldBuilder with their own workaround)

I then went to Excel to try some things since it is a much lighter application than attempting full-scale in Lua code and 2-ish minutes to go through the map setup & generation in Civ. After scrating my head and trying to figure out how to simulate a hexagonal map on a rectangular grid, I made an accidental discovery ... the only difference between a hexagonal and rectangular grid is a half-tile offset on every odd-numbered (or even numbered) row  eek It took a bit of mind-gymnastics to visualize at first, but it was definitely easier to work within the rectangular grid of Excel. The following is what I came up with as a quick-and-dirty method for distributing the land and water plots in a somewhat balanced yet non-mirrored and randomly distinct manner:

(1) Set up a base pattern within which to work:

   

I went with a snaky continent, bouncing up and down between the various starting blobs. 6 players with 2 land neighbors and two water neighbors. The numbers represent different regions, the coloring is conditional formatting to help identify that the regions were all assigned correctly. I split the continent into 4 areas. Each would get an individualized percentage modifier for the likelyhood of that tile being LAND vs OCEAN.
  • [ocean, designated numerically 0 and alphabetically "o"] would be predominately water and get a very low land percentage
  • [mainland, designated numerically 1 and alphabetically "m"] would be predominately land and get a very high land percentage
  • [borderland, designated numerically 2 and alphabetically "b"] would set the smoothness of the coast. 0% or 100% would give perfectly smooth coasts, 50% would give randomly broken and cove-like coast
  • [island, designated numerically 3 and alphabetically "i"] would control an off-shore island mass between the players. Higher percent gives solid island, 50% gives snaky island, less gives a couple of spotty islands.
(2) Example with specific set of percentages. As a proof-of-concept the actual numbers aren't that important, but I'll list below how I have it set up:

   

The panel on the right has the parameters and input values. Inputs are highlighted in YELLOW, GREEN is the approximate tile count from each region, ORANGE are the theoretical number of land tiles in the given region based on the input land percentages and the total number of tiles in the respective region. The OceanLand and IslandLand percentages are calculated values with a hard-coded 80/20 split between the island regions vs. randomly throughout the Ocean region. If the % island would exceed the IslandMax value setpoint then the additional land is allocated purely to the Ocean region. Above the parameters is the actual total number of land tiles generated.

As you can see above, as the Ocean percentage increases there is greater likelyhood of player starting blobs getting a secondary connection through and island region to an adjacent player.

(3) A couple more screenshot with various percentages:

   

   

(4) Implementation into Pangea.lua and map generated in World Builder:

   
Reply

Awesome work Cornflakes!
Suffer Game Sicko
Dodo Tier Player
Reply

That looks amazing.
Current games (All): RtR: PB80 Civ 6: PBEM23

Ended games (Selection): BTS games: PB1, PB3, PBEM2, PBEM4, PBEM5B, PBEM50. RB mod games: PB5, PB15, PB27, PB37, PB42, PB46, PB71. FFH games: PBEMVII, PBEMXII. Civ 6:  PBEM22 Games ded lurked: PB18
Reply

That's very neat! I like your approach!
Reply

The downside is that with the base zig-zag pattern hard coded players will know within about 5 turns whether they are in the northern or southern hemisphere and will then know exactly where all other players are located. Is a regular zig-zag such as this too uninteresting? Does it negate some of the allure of exploration in the great unknown? The only things that vary from game-to-game geographically is the specific nature of the shoreline coves and islands. Some variation can certainly be achieved by experimenting with the percentages. At the extreme ends of the percentage spectrum, this base template creates an excellent lattice "lakes" pattern ... but in the end of the day, everyone knows the pattern.

The question is then, from a large-scale geographical perspective, what is important (or essential) in a multiplayer map? How many land tiles per player is appropriate? How far apart is too far / too close to start? What is a good trade-off between balanced geography and boring terrain? The answers to this can help determine either a better starting patter, or an algorithmic means of generating a pattern. Surely such question have been posed elsewhere on these forums.
Reply

But can you use this method to design other map types?
Current games (All): RtR: PB80 Civ 6: PBEM23

Ended games (Selection): BTS games: PB1, PB3, PBEM2, PBEM4, PBEM5B, PBEM50. RB mod games: PB5, PB15, PB27, PB37, PB42, PB46, PB71. FFH games: PBEMVII, PBEMXII. Civ 6:  PBEM22 Games ded lurked: PB18
Reply

As PB37 shows, "balanced" geography may not be what it seems. Very uniform geography simply ends up highly accentuating the differences that do remain, and makes them obvious to boot. Mirrorlike scripts seem to end up being some of the most unbalanced ones.

If not a strict mirror, I would go for "interesting" every time. It also gels better with the large diplomatic/foreign relations element in any MP FFA.

Important is equality in the number of exposed fronts, equality in access (or lack of) to safe back lines, in access to sea if relevant, e.g. settleable overseas territories, and that's about it from a high level perspective. Land per player and optimal starting distance are not real concerns -- cramped maps can be interesting, sparse maps can be interesting. 1UPT makes an issue of proximity pretty vague too -- how proximate are two civs if their immediate only connection is a two-tile long, 1 tile wide mountain pass, hilly and cut by a river?

TL;DR -- any fractal blob (e.g. http://marksworld.zeemer.com/files/maps/Highmap.jpg) is fine as long as mountains are used smartly to balance fronts/necklines and no-one is dumped inland.
DL: PB12 | Playing: PB13
Reply

(October 12th, 2017, 17:10)Krill Wrote: But can you use this method to design other map types?

This method could probably be used to generate map types using either by generating template shapes (like Cornflakes has done) or replacing the built-in fractal generators with customs ones.

Partly inspired by Cornflakes and partly because work is s---l---o---w right now I've actually started a deep dive into the map script files.  Of course, I have no idea what makes for a balanced Civ map or have ever attempted to program something like this before so this is currently an "academic exercise in curiosity".
Reply



Forum Jump: