Map Generator 2.0 - Please Critique!

This thread is an extension of my previous Map Generation thread(Map Generator- Please Critique! - Blueprint Visual Scripting - Unreal Engine Forums.

I wanted to start a new thread to show my updated progress while leaving the earlier thread intact for people to reference.

The Map Generator currently procedurally creates a map that factors in landmass creation, elevation generation, climate banding, precipitation regions, and coastal formations. There are currently 9 vegetation types with 3 elevations. All the rendered tiles are Instanced and invisible Collision Volumes are spawned on top of them to handle tile interaction. World Wrap is currently functioning in a basic manner. Everything scales to Map Size in increments of 10 with 10 being the smallest map. The terrain Seeds for the map shown below are completely random.

This baby took 1 minute 49 seconds to generate. At least 50 million iterations. Size 60 = 120x60 (7200 tiles, or 1/3 the size of a gigantic map). This is a pure random biome generation. Everything is seeded, but the seeds are randomly placed. Continents, Pangaea, etc will come in the future.

For reference:
Arctic = Snow
Tundra = Snowy grass
Boreal Forest = Snowy Evergreens
Coniferous Rainforest = Evergreens
Deciduous Forest = The average Green trees(The ones with the shading problems)
Jungle = Bluegreen Palm trees
Grassland = Green with a couple trees
Steppe = The browner grassland with no trees
Desert = The sand colored tiles
Arid Mountain = The red’ish rock mountain
Mountain = Rocky with snowy peak
Arctic Mountain = Completely snow covered with a little rock showing.
Marsh = Teal with ponds
Lake = Deep Blue
Coast = Blue Green
Ocean = Dark Blue


Vector Field Generator - First Loop runs X. Second Loop runs Even Offset Y. Third Loop runs Odd Offset Y.

The Vector Field is Indexed as such:

After the Vector Field is generated, it can be Seeded. The Seeds are basically what determines how the map actually looks at the end of all the generation. Landmass shapes, how rocky/flat, how wet/dry, etc.

First, the Vector Field is seeded with Water and Land seeds and the vectors of those Seeds are stored in the Ocean and Earth Vector Arrays.

Second, the Earth Array is seeded with Elevation seeds for Plains, Hills, and Mountains, each of which create an Array.

Third, The Earth Array is seeded with Precipitation seeds for Arid, Semi-Arid, Moderate, and Wet climates, each of which create an Array.

Once all the Seeds are in place, it is time to grow them.

The Generic Biome Locator is the key Function behind growing the seeds. It finds the distance between the nearest seed and the current tile to be generated. Shortest Distance(Dist) gets set.

First, the Water and Land Seeds grow into the Oceans and Landmasses and fill the Sea Level Array.

Second, the 3 Elevation Arrays are run in the Land Array. Each is then compared to the Vector Field to set the proper equivalent Index in the Elevation Array.

Third, each Index in the Land Array is run against the Range Find function to see what Climate Band it is in and the Temperature Array is set accordingly.

Fourth, the 4 Precipitation Arrays are run against the Land Array. Each is then compared to the Vector Field to set the proper equivalent Index in the Precipitation Array.

Finally, the Water Depth Generator sets each Water tile next to Land as Coast, and the rest to Ocean.

By now, the 5 arrays responsible for holding all of the map information have been set. Now we need to actually spawn the map.

As you can see in the overview in the Map Spawner box, there are 3 sets of loops that spawn 3 sets of maps. This is to simulate a seamless world wrap, but will probably change in the future.

For each Index in the Vector Field the equivalent Index in each of the arrays must be referenced.

An Enum for each Array guides the flow to the correct Add Instance node.

The Plains, Hill, and Mountain Instance Spawners each look like:

Tile volumes are also spawned and are used for tile interaction since the instances don’t have individual collision responses(they act as a single entity for collision).

Here is a pic with the tile volumes made visible with a glass material. As you can see, hitting a volume and changing the underlying instance also changed the same Index on the shadow map to the west. All 3 maps had their instances cleared and regenerated with the update, which was basically seamless:

The Sea Level, Elevation, Temperature, and Precipitation settings scale to these charts:

And Uniformity, which determines how large each biome is. The Sahara would be a large desert biome, while the Mojave might be considered a small or medium desert biome:

As with the other map settings, resources generation will be configurable in the map setup screen:

During the initial map generation, the map is seeded with all the resources that stone age man used on an important, simulated scale:

Then, as the time goes on, techs are learned, etc, both more and new resources are seeded onto the map. Here is what the map might look like in the Bronze Age:

Here are the resource seeders. Each resource spawned on the map will use 1 of these, for both initial generation and any future generations:

Here is the inside of a resource seeder:

Tree Generator:

I generate a miniature(or you could say monster by the look of the function) version of my vector field for the trees. This is done only once at the start of map generation and each of the 37 trees placed in each forest already has a predetermined offset compared to the center of the tile it is spawning on.

And then I use that vector offset array to reference when placing them, while giving each tree a random x/y bump from its grid point. This is done once per forest to be spawned.

Wow this is amazing, Ive done my own tables before but these are very nice. Are you using the spreadsheet import? The blueprints too, all look big. I think I might make a suggestion (to Epic) about snapping variables to the setter, enumerators are the main one. In your array getter/setter you have used the better smaller nodes, I think these should extend to operators.

You have done a great job, Im really impressed. Can you stack tiles like that? Displaying only the ones you see, for instance the sub-tropical/temperate might be more of a fall off like corrosion and the same for under water you can have rocks. Mountains compared to water for instance, you can have cliffs and there was a spline tool for roads coming up in 4.2 wasnt there? I just cant believe how much detail you got here, is so easy to read but we could use with collapsing the for loop right :slight_smile:

Thanks, I will share more with some macros, I can share the varying hieght but its not that tricky when you have the locations

Its bigger than it looks I hope, this is how I achieved:

Did the tables in google docs for my own visual reference. Hopefully I can get a similar visual representation in the game when it comes time to work on that.

What do you mean about the blueprints looking big? And the snapping variables/smaller nodes?

Thanks. :slight_smile:

What do you mean by stack tiles, like the dual material stuff in the content examples? That could get pretty expensive performance wise. For transitions between climates/terrains I can probably get by with swapping out meshes. For instance, right before placing an instance I could do a neighbor check to see what kind of neighbors are around and apply decals, change the terrain, etc. Similar to the coasts. Would have to play with it and see how much I can get away with before draw calls and map generation time get out of hand.

Is the spline tool making it to 4.2? I could definitely use something like that for rivers and roads, so hopefully it comes soon! May be awhile before I start working on those anyway. I was thinking of some alternate methods of river generation in case a spline tool wasn’t available in time. Shouldn’t be too bad either way. :slight_smile:

That macro looks like insanity… :stuck_out_tongue: Hard to read your whole blueprint though, maybe better if you split it into smaller screenshots.

What are you going to do with that giant hexagon forest again? :slight_smile:

Oh its just something Ive noticed is that Blueprint can still be improved on, Im not sure if you’ve had any ideas whilst you been using it on how to improve it. I was thinking that variables could be snapped onto nodes to save space, if you look at the array add node vs something like the boolean and the boolean node is much bigger, I wouldnt mind that style being extended because it saves more space. UE4 can actually work with CSV files from spreadsheets so Im not sure if that might be useful to you at some stage or if you can do it all mathematically, sometimes having the raw data can speed up generation times.

Well the first thing I thought of when I saw your tables was using a 3D array so you could stack water tiles onto of the lower land tiles and see through, or have the land tiles at different heights similar to what Im doing but perhaps not so extreme. For instance you could stack mountain tiles onto of plains and just remove the top layer to get more plains, it’ll certainly be expensive but it might allow you to visualize the difference between the map layers when adjusting it more freely but you’re right at this point Im having to cheat with instances alot to get better performance and Im around the 20fps mark in the picture Ive shown :slight_smile:

Looks that way, It should be out later this week if everything goes good so Im sure that will be helpful. Atleast its something you might not have to worry so much about doing manually now so thats a bonus :cool:

If you rmb and copy the url for the image into a new tab its easier to see the whole thing, its quite large and the forum auto sizes images. Im just toying with a few things atm to do with the material, its actually coloured, choose metallicness n roughness randomly now just for some fun but I do need a better algorithm Im wanting to adjust the floor and ceiling so that they are more common options and in between is less, Im just toying with the idea but I was hoping to use it for a map with giant moving stone pillars that are hex shape.

In terms of what Im planning on trying in this little prototype thinggo is well, I could try generating some kind of hex cave or the thing I really wanted to try and thats adaptive view distance so as you get closer to generates more hexes from the larger ones, breaking them into smaller more refined patterns. Im super busy though and I keep giving myself new projects, probably not the best idea but I really want to get back on this and try some more things out, I just wanted to share what I had so far incase anyone wanted to use it in the meantime, if it perhaps help you alittle bit. Im curious, did you end up using the code that removes the iteration limit from blueprint?

Oh yeah, being able to snap variables onto the nodes could be pretty cool. Of course I would want them to jut out a little bit for easy visual reference.

I was thinking about using xml for data storage because I have seen it used in many other games and it makes modding easier which is something I would like to support.

Ah, I was actually thinking about using that but with Forests and not so much Mountains/Hills. So I would have a terrain layer, and if you change a mountain to a hill then you regenerate the terrain layer. Then you have a vegetation layer, and if you chop down a forest you just regenerate all the forests instead of the entire map. Regenerating all the instances seems to be a pretty seamless operation, so hopefully it works well when I scale up.

For sure! I would rather put a river system in prior to working on resources anyway, so the timing is good. :slight_smile:

Cool. Much easier to read when I go to the link, though you still have some spaghetti knots in there… :stuck_out_tongue:

I like the map generation time counter, but it is returning 0.0 seconds for me. Counting 4 seconds between clicking play and game load.

Not yet, but I do have it bookmarked and I have thought about it every so often. The only reason I haven’t used it yet is it doesn’t have any attached instructions so I just haven’t taken the time to figure it out and it hasn’t been a pressing issue anyway.

Is this all I need?

It says plugin but I have no clue what to do with it. :stuck_out_tongue:

Thats what I was thinking as well, having them the same node shape just poking out would be cool.

Yeah if you are needing to save out big datasets you might want to start looking into that, either using XML or the inbuilt save games in blueprint, that way you can pull the data back in without having to regenerate it each time.

I think that is a really good idea, Im curious how far things can really be pushed as well thats why I wanted to attempt some kind of lodding feature thats alittle more seamless, ofcoarse there is streaming levels but perhaps that will work better on vegetation and other details like cities rather than the actual landscape. Right now Im wondering to adapt mine to get some more material variation, I might have to iterate multiple sets like you are doing for your biomes but getting the terrain variation in terms of Z axis is high on my list too, perhaps I can replicate a sea level and do that as a seperate pass after the heights are finished :slight_smile:

I’ll look into that, I think it has to do with it not ticking until the game becomes active and the majority of the script is run in construction so I think thats why the counter doesnt work. Im not sure where I can find something that ticks during or before construction, it does tell you how long it takes to bring the level up for play so Im not sure if thats a close number.

I might try to make a compiled version for you to use, Ive found using while loops in blueprint is almost useless with the current iteration limit, sometimes you want alot of iterations in a short space of time especially when you consider something like polling input.

Yeah, whenever I start working on persistent data I will do some research. :slight_smile:

Well it seems right now you can’t procedurally generate tiles into a specific level. They did add the ability in 4.2 to instance a streaming level into the world, so that is one step closer but not quite enough. I should be able to stream whole copies of the map that appear off screen but right now I have no way to tell what level a tile needs to spawn in so they just pop into the persistent level.

Yeah you could do some cool stuff like make a block of hexes generate at max height, some at mid-range, and then some at max depth and use the same byte to run height specific effects on each of them. I plan on doing similar things when I start generating resources, so if a tile is Hot and Wet, then it has a chance to spawn say, Bananas, Rubber, Hardwood, etc. Cool and Wet might instead have a chance to spawn Furs, Softwood, etc.

I fixed it by adding a .2 second delay at the start of my map generator BP. I also put delays in front of each of my heavy Generator functions which seemed to speed up the general execution. There is a slight pause after hitting play, but the map basically generates in .55 seconds and that is with 5 .1 delays.

So that would basically be compiled as a plugin that I could just drop into a folder and then activate in the editor? Something like that would be great!

I am probably going to need the limit raised to 10 billion… :stuck_out_tongue:

Sea Level now scales to a single map setting.

Here is a map generated with a Sea Level setting of 2. All previous pictures showed an equivalent Sea Level setting of 5:

Was pretty easy once I got everything straight in my head. A 1-9 Enum with variables that get set based on the spreadsheets that I posted above. Then a conversion to bring the set variable in line with the seed input.

Sea Level, Elevation, Temperature, and Precipitation now scale to the Map Settings.

Here is Dino Era Heat:

And Ice Age Cold:

Going to need to work out something for Sea Ice at some point…

Now I am going to create a Uniformity setting. Do you want vast plains and mountain ranges, continent spanning deserts and jungle, or something a little more mixed up? Uniformity is the setting you would use to play with how diverse various Map Settings are. More uniform = large continuous biomes, such as the Sahara desert. More diverse = biomes that often split up into much smaller chunks.

Essentially, Less Seeds = More Uniform. More Seeds = Less Uniform.

Uniformity/Diversity implemented:

Level 1 Uniform Land & Ocean:

Level 9 Diverse Land & Ocean:

Precipitation and Elevation can also have their uniformity adjusted.

Updated my volume actors to work with the new system. Also had to make it so that updating the Main Map or either of the Shadow Maps reflected on all 3.

I am also moving from a Tile Volume system that had a Child Volume for each tile type to a single Parent Volume that simply handles interaction by vector index and then use that information to update all the relevant arrays that actually hold the tile relevant data.

Using a glass material for Volume testing purposes. As you can see changing one tile affects the Shadow Maps as well:

Regenerating 3 maps is just as seamless as regenerating 1, so that is encouraging. :slight_smile:

Great stuff, yeah I should be able to compile it provided it works for 4.2 just really busy but hopefully I can do it tomorrow :slight_smile:

The updates look amazing, this is really coming along I can see the organic feel starting to take shape and your design is very detailed, Im quite impressed with the amount of detail youve gone into with your graphs to outline each of the different blends between. I always prefer to play on archipelago type maps for some reason, big land masses are okay but I prefer to have something to use for cover, Im actually really curious to see these resources youve been mentioning too if this is the detail level you had just for land masses.

Thanks so much for sharing :cool:

Glad you like it!

Resources are a work in progress. Basically I have a huge spreadsheet with all the plants, animals, aquatic, and organic luxury resources(in existence just about) organized and categorized. For the design I can either take that super detailed, down to the vegetable, or I can keep it more streamlined by using the broader categories such as Grain, Fruit, Vegetable, Livestock, Poultry, Fish, Crustacean, etc, etc. Leaning towards some hybrid that utilizes as many resources as possible while keeping the game as playable as possible. Unlike other civ games I intend for you to be able to take an organic resource(such as Sheep) you find in the world and basically farm it wherever you want to. Your people will demand some diversity in their food supply though.

I still need to create the mineral spreadsheet with all the metals, stones, gems, etc. I am leaning towards Metal, Hydrocarbon, and Stone being the 3 primary categories though. I might break those down even further for generation purposes.

Resource generation will take place in 2 primary layers. Mineral/underground layer and the vegetation/above ground layer. The mineral layer will be broken up further into quasi-layers to allow advanced tech to unlock deeper resource extraction over time.

I am considering having the minerals generate as biomes, with dead spots that could allow you to generate complete scarcity, or resources under every tile. As uniform or diverse as you like of course.

I am also considering having a toggle to let you view the underground resources, but that could be too cumbersome. Though if I use 2 layers then it may be a necessity.

The key in all of this of course is to make it as seamless and easy to work with as possible.

Anyway, once I have laid out and categorized the resources I will be able to work out exactly how they should be generated.

Looking forward to the spline tool for the rivers too!

I can now cut down forests individually. All forests clear to a grassland, though that may change somewhat in the future. A Bool Array tracks whether each tile has had trees removed or not. This allows a forest to be cleared without affecting the precipitation array which is what drives forest growth in the generation and regeneration of the map. I could put a turn timer on each cleared tile to determine when it’s bool would reset to false and regrow the forest, or the forest can easily be manually replanted.

I am thinking about beginning some resource work, but I need to figure out a good way to display them. At some point I need both a kind of quick visual display such as hovering icon or decal, and also an on-tile method such as having cows hanging out in a field.

Right now I am just thinking about the icon/decal. I can worry about details and prettiness later, but generally I want to get the basic system up and running that will eventually have all the bells and whistles hanging off it.

So given I may have dozens and dozens of resources visible at any given time, what is the best approach for a floating resource icon? Instanced meshes? Invisible meshes with decal printed on them?

What do you guys think?

Updated the OP with the new Seeder images. They include the map setting inputs I mentioned before.

Researching mineral resources to add into the game has me dreaming about mining… lol

I have about 15 key metals, metal groups, and hydrocarbons. Need to work out the various stones and important mined chemicals(maybe another 10-15 resources), and then I should be able to begin work on resource generation.

Also need to create some icons for the resources.

Is there an asset type that would best handle images? Something that can display a little imported picture?

Updated the Generic Biome Locator which should now use ~60% less iterations for each execution through the locator.

I also modified the generators so they break the loop when they find a tile that is less than 1 tile width away. This cuts the number of executions by about 30%.

Map generation performance gain on a map size of 200 tiles is small, maybe 5-10%, but should be quite noticeable on the larger maps.

Still working on the foundation behind the resource system. I am juggling the possibility of having ~60 organic resources which would not really be represented on the map by icons as you see in other civ games. The idea would be that you find say wheat, and then your civilization gains the ability to plant wheat in all it’s farms. In previous civ games, you would see a bonus wheat resource on the field and that is it… you can’t do anything with it except work that one tile. But that also meant that an icon would represent the resource since it was a special tile. I can take the reproduce-able resources off the map other than their graphical representation such as a pasture with cows, and play with them more on a city/empire level by making the people want more or less of certain resources without them cluttering up the map space.

Then I can use the map to show the important, non-reproduce-able inorganic resources such as metals, minerals, etc.

Organics could essentially generate on the map kind of like bonus huts. You find it, and then your civilization gains access to that resource type to fill it’s farms, pastures, and plantations with.

Inorganics, of which there are currently 16, would generate using biome generation similar to what I use for the map. Oil fields, iron deposits, etc would all seed and grow through the map. You could have some small oil fields, and then you could have some saudi arabia size oil fields, which of course will be adjustable with all kinds of settings during game setup(similar to the other map settings). I am also considering some way to reveal some resource deposits only through certain tech advances. So some oil is revealed first, and then say fracking tech unlocks vast new fields.

Fish are a bit of a dilemma since they are technically reproduce-able organics, but unlike say cows, they don’t really fall into that category until near the end of the game. And I can’t simply treat them like inorganics and biome generate them since they would have to share territory with oil and other undersea minerals(which are also potentially very late game additions).

Here are some resources that are randomly generated:

Mostly just getting a feel for how it sits on the map.

Deciding the best method for simulating and representing resources has been harder than I first imagined.

Organics, other than fish, will probably not have icons/text on the map, but will be found once, then unlock the ability for your empire to farm them en-mass.

Inorganics, as shown in the above map, will probably have some kind of presence on the map, though I am still working out the details.

I am also leaning towards a mining system that is unobtrusive to the overall game map. Shaft mines and oil wells generally don’t take up a lot of space, so I am contemplating having them coexist with farms and other normal improvements. But, if you really need lots of ore in a short amount of time you can open pit mine them which utilizes the whole tile, gives more resources per turn, costs more gold to run, and may exhaust the resource sooner if that setting is turned on.

Almost the same question

Thank you for posting your Thread.
But you are so technichal and it is hard to understand without any examples
Can you share something with the community?
I faced with similar problem and it turned out that you have advanced a lot better then me

This is my separate question and video

Please help!