Map Generator 2.0 - Please Critique!

Randomizing the tree spawn was easier than I thought. Didn’t have to adjust Z for the hills thankfully. :slight_smile:

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.

Got the spline tool working with a water mesh:

Going to start working on a river generation system.

I am kind of torn on river placement though. I have 2 options, both with pros and cons:

  1. Flow the river through the middle of the hex.
    Pros:
    +Easy use of the current coordinate system.
    +River can bend in 5 directions.
    +Easier to make tile improvements like Dams/Lakes.
    +Easier to show rivers as a method of transportation and trade.
    +Easier to show rivers going around elevated terrain.

Cons:
-Trees, Cities, etc must be visually displaced to make room for the river. But this may already be an issue with roads anyway…
-More difficult to simulate attacking/moving across the river. Though attacking a tile with a river in it could be the same as crossing it in the other system.

  1. Flow the river along the edges of the hex.
    Pros:
    +Trees, Cities, etc don’t need to visually account for rivers.
    +Creates a clear line where attacking and moving is more difficult across the river.

Cons:
-Requires a modified, or even a completely separate coordinate system.
-River can only bend in 2 directions.
-Harder to show rivers going around elevated terrain.

Leaning towards option 1. What do you guys think?

Here is a picture of both river methods in action. On the left, the river goes through the middle of the tile. On the right, the river stays on the edges.

As you can see on the left, the trees that sit on top of the river spawn would have to be removed. Also, the river has some unnatural looking angles when it is doubling back, but those can probably be smoothed out somehow. Actually, I may not want the rivers to double back at all. It may just create a mess on the map without really benefiting the simulation. I am inclined to make areas that have several river tiles next to each other into lakes. The same for rivers that flow into a dead end of hills and mountains.

The river on the right looks much cleaner as it winds around the trees. Its limited fork options may actually be a benefit since it makes it more difficult to double back on itself. Also, if I did need to go through hill regions, it would look more natural since it would slide between the hills as if through a canyon.

I think I will create a coordinate system for the rivers that flow around the edges of the tiles. I can use the current Vector Field as a base, and as each river is spawned, give each Vector 6 sub-vector offsets where the river spline points will be located. The hard part will be determining which side of the hex the river will flow around. I suppose the first pair of spline points can be random around the hex, with a given direction of flow, and then it flows from there.

So a tile with Wet or Moderate Precipitation would almost always be the originating tile for a river, a check could be performed to see which nearby tile has both high precipitation and high elevation, and start the river between those 2 tiles. Then the river will flow with a preference for downhill, towards wet precipitation, and towards ocean.

What will be the end goal for this?

A civilization type of game?

Pretty much.

Sometimes you just don’t realize how small something is, until you make it 36 times bigger. :slight_smile: Thanks to Rama for adding a loop limit removing node to his plugin!

This baby took 1 minute 49 seconds to generate. At least 50 million iterations. 120x60 (7200 tiles, or 1/3 the size of a gigantic map)

Well as least I don’t have to make a Seed for archipelago, cause that seems to be covered with random distribution. :stuck_out_tongue:

Still chugging away at the river generator, but as soon as that is complete I think I may take a look at some tectonic based map generation.

Edit: Yep, got some optimizing to do. Size 200x100 map(20,000 tiles) was on track to hit 24-30 minutes on generation time before I hit the loop limit in some random function. Its ok though, because currently each tile in the map is checked against every seed which may or may not be 100 tiles away and that will be addressed. :slight_smile:

I want that Looops! :smiley:

I will trade you a billion loops for a neighbor checking system that doesn’t melt my brain… :stuck_out_tongue:

It lives, it lives!!! Mostly… :stuck_out_tongue:

There are 3 rivers generated on this map, one looped on itself immediately and the other 2 managed to go a good distance before dumping into the ocean.

I am going to have to do something about the rivers looping and dumping into themselves, but other than that it is looking pretty good! :slight_smile: The artifacts caused by river merging are really hard to notice without zooming way in so should be pretty easy to cover up. Also need to create some delta transition as it dumps into a body of water.

Creating the river generator was an epic undertaking that I didn’t fully appreciate when I started. This block of code added 35 Functions, 2MB to the size of my blueprint, and took dozens of hours to complete. I was only able to test it 2 hours ago.

Each row corresponds to a corner of a hex used for reference for each spline point, starting with 0 in the upper right(North East) and moving clockwise to 5 at the upper left(North West). At each point in the river growth, a single tile is used as a focus for neighbor searching and river forking. The generation loops on itself until the river dumps into a water tile or another river.

I may go more into depth on this generator at a later date, but it might need its own thread.

Well I will be traveling for work next week so I won’t get much work done, but I should be around the forums. Just glad I could get this working first. :slight_smile:

Holy ****** of wires! :eek:

Hehe yeah keeping it straight in my head with all the offset compensation, world wrap, and generation possibilities can be a nightmare.

Amazing work as always, Zeus! Love the river splines. You’re making a lot of progress, but I’m wondering how you have planned to differentiate your game from Civ V. After you’ve laid the groundwork, what are your plans for making your game stand out? What will be the reason people will want to play your game instead of Civ V?

As for my own work I haven’t been working on my pathfinding system since my last post, between moving and vacationing, but I’ll be returning to it very soon. I’m thus very interested in learning about how you managed to remove the loop limit. That would be a great help as I strive to make my system more efficient.

As for finding a method for selecting neighbors that doesn’t melt your brain, what are you using now? For my square array I select cells with the array index +1 and -1 as well as [current index - array width] and [current id + array width]. That’s pretty straightforward, I think, and I can’t imagine it will be much different for a hex grid.

edit: changed id to index

Thanks!

For differentiation, quite a few things will be different. Civilizations will share a tech tree with development projects such as stealth being civ independent. There will be a more robust government system. Units will likely travel in packs of 10 instead of 1 or infinite. I am also contemplating some kind of deployment system for military units that doesn’t have them all over the field all the time. Trade will be more important. The map will be utilized in a more realistic fashion with towns, factories, power plants, etc. Resources will play a bigger role.

I haven’t really settled on any genre defining selling points, but there will be a huge number of differences.

To remove the loop limit, look at Rama’s plugin post. Just download it and put the loop limit node in whatever functions are giving you problems.

The problem with hexes is the offset. I have 6 functions for odd neighbor checks, 6 for even, 4 more for world wrap, and then I have to take into consideration both world wrap and the poles when doing anything with a neighbor check which means lots of branches and me having to make sure I am using one of the 16 correct functions with all the correct branching for wrap, poles, and other factors.

Right now my neighbor checks are 1 tile away. I truly look forward to seeing path finding that takes into account the world wrap. :slight_smile:

Hello , i’ve been away from your threads for a bit, first because i was working on dungeon like-map generator, second because summer, kids, hollidays, you know what i mean :stuck_out_tongue: but eh each time i have a look at your project, each time it looks greater ! thanks for all the things you learned me and hope your project will be great. ^^

Great, I’ll check out the plugin. Extremely useful. I look forward to seeing your game evolve. Creating systems for grand strategy with trade and diplomacy in blueprint will probably be tricky, but also a fun challenge.

You might want to use a 3D-coordinate system like the one used in Amit’s tutorials if you want to simplify the neighbor checking, though it might make your blueprint more complex in other places.

I won’t be needing world wrapping for my own game, but I can’t imagine it will be that tricky to select neighbors on the other side of the wrap. I’ll think about it as I keep working on my pathfinding.

Thanks for your support, and good luck with your own project! I know how it is with the kids. I got 2 and all I do is work, play with the kids, and build blueprints. :slight_smile:

I am always keeping an eye out for procedural generation related posts, so hopefully see some of yours soon!

I cannot wait until I can start working on those systems. Once I get the map generator fully stood up and all the various map systems such as improvements, cities, unit movement, etc I can begin to focus on the actual AI and all the systems that come with that.

I will have to check that out. Amit’s stuff is exceptional.

On a single tile basis it is pretty simple, apart from making numerous other systems more complicated in general.

The part that I have not worked out yet is neighbor checking across those borders at a much larger scale. I have a feeling that pathfinding algorithms in general have the answer, and I probably need to look at what Amit did for Wrapping.

One thing I did run into but didn’t spend much time to figure out was actually doing distance checks across that wrap. My current generator can not do it because it uses basic unreal world vectors and I need some way compensate for a distance check that is basically 2000 unreal units but needs to be treated as say 100, and scale for every tile in the map.

Amit’s explanation for axial coordinates can be found at the end of the second section here: http://www.redblobgames.com/grids/hexagons/#coordinates

It’s a very elegant solution compared to using an offset, and it is the method that Amit recommends. I’ll be using axial coordinates when I expand my pathfinding system to hex-grids later on.

New after edit: I’ve only had to check for adjacent neighbors so far, and here wrapping is, as you say, easy. In fact it is so easy that it happened by itself and I had to adjust my blueprint to stop it.

I saw that article before but I didn’t use the axial system because offset already fit the kind of map I was looking to create, and was easier to understand for what I was trying to accomplish at the time.

Now that I have had my fill of offset neighbor checks, I will take the time to understand the cube and axial coordinate systems.

Working to remove the river looping. Got a little more tweaking to do, but it is looking good:

That is 3 rivers branching into 1 which dumps into a small sea. I circled the start of each river in red, and the points where they merge or dump into the ocean in green.

I cleared away the forests in that area for better visibility.

Also got some work to do regarding the look of the rivers at the start, end, and as they merge in certain circumstances(such as the start of one river meeting the end of another instead of somewhere in the middle).

Hello ,
not checked your generator since a moment because i was more on inventory / character action and then summer with kids but hey ! So great ! It goes bigger and bigger ! GRTZ !

(Next step, make your map going out of the computer to prepare coffee for the day ^^)