The rivers aren’t appearing out of nothing, though it may appear that way so good feedback. Since the river spawns between tiles it is hard to tell which tile it is actually spawning on. Maybe I can fix that by offsetting the start position to lean into the tile a bit.
So right now, where the rivers spawn is mostly random until I work out an actual weather system. 2/3 of the rivers spawn on/next to a wet tile such as a jungle or coniferous rainforest, and 1/3 spawn next to a moderately wet tile such as a deciduous/boreal forest.
I wouldn’t say that “most” rivers start on or around mountains, though they certainly play a huge role in global weather patterns. The way it would actually work(off the top of my head) is that I have lets say a regional weather pattern direction, and then mountain ranges. On one side of a mountain range you would have lots of wet tiles(Pacific Northwest, Amazon, etc), and on the other side lots of dry tiles(the rain shadow). Not a hard rule, but something I want to try and take into account at some point. Either way all rivers start from areas of higher precipitation. I don’t know if I will simulate rivers resulting from glacial melt, perhaps not. Anyway, any river of a size large enough to simulate in a civ game is not a mountain stream, but a potentially continent spanning river, which may or may not start on or around a mountain.
Really though, I have yet to work out any actual generator for mountain ranges, weather patterns, etc. Everything is random at this point. If you look at the screenshots of my seeds, the blueprints that determine where things actually spawn, you can see that they are quite basic. When I implement tectonics and weather patterns those will grow quite a bit, as will the river start.
So yeah the algorithms don’t need to be changed, they need to be created.
I am going to assume you mean the map generator. I am making a game similar to civilization. Right now I am working on map generation and interaction. It would be difficult to explain what is going on without re-posting everything that has already been said in the thread. I suggest reading the first post especially. If you have any specific questions I can answer those though.
Implemented multi-tile lakes. If a body of water is less than X(right now 7) tiles in size then I designate all those tiles as lakes.
More importantly, every continuous landmass and body of water gets grouped together in an array which I should be able to access later and use the information for other purposes such as:
Spawning players on the same or different continents.
Spawning players on islands or continents.
Having immediate knowledge whether 2 players/ports/etc are on the same landmass or body of water for trade and AI path finding purposes.
Balancing resources based on landmass and body of water.
Using the information for territory claiming, especially with the AI.
Perhaps another half dozen things I haven’t thought of yet.
Now I have to fix a part of the river generation that snakes all throughout the lakes. It actually wouldn’t be too bad if I could hide the rivers under the lake until they pop out the other side, but there are other issues I would have to deal with as well. I am thinking the river will end in the lake and then call an event that pulls a random tile in the lake and spits the river out that end assuming it was a valid choice.
Got sidetracked by a flaw that I just barely caught. I had to put some more checks in a few places to ensure the top and bottom edges of the map were being properly accounted for when neighbor checking.
In this pic you can see the lakes that are the darker blue surrounded by land. The lakes are key because they will count as sources of fresh water in game and influence river flow. Right now anything smaller than 7 tiles is a lake, but I think I will make this a setting that you can select on map creation for players who want anything between maps covered in lakes or maps only containing saltwater, and also a setting to allow a certain number of lakes to be salty from 0 to all of them.
If you look closely you can see some of the rivers running rampant through the lakes so that is what I am going to work on now. When I am done a river will enter the lake and then exit from a randomly chosen tile.
Going to have to create some diagonal neighbor checks and a couple other systems to get that to work. Biggest problem will be figuring out whether the destination tile is valid.
I see. In that case I’m impressed that you’ve gotten the maps to look reasonably natural. On the surface they look like something that just needs tweaking instead of implementation of whole new systems, so I think you have an excellent base. I love that you aim high, and are planning to implement tectonics and weather patterns. Looking forward to the day when I can play the finished game.
Thanks. I look forward to the day I can play a very simple prototype… Most of the systems in the game should hopefully be cake(comparatively) once the map generator is complete. AI will be the next big challenge, but that is ages away.
I’m worried that the other systems will be a lot harder to make than you might expect. In my own (admittedly limited) experience, distant parts of the game always seem much simpler than the ones you are working on at the moment, since their complexity is only revealed when you start working on them. And of course there’s the old saying that the last 10% of the job takes 90% of the work.
I can sympathize, as I have much the same feeling for my own game. Now that I’ve finished my pathfinding system it is slowly dawning upon me how much work will be needed for the next step. Still, I do agree that your map generator might very well be among the toughest parts of your game to make, and as long as you manage to keep your motivation up there’s no reason why you shouldn’t be able to complete your game.
My only worry with the simple systems is that there will be so many of them the combined complexity will be a problem. Then getting the AI to work with it. Hopefully I can make the foundation modular enough from the get to go to make it easier to handle. We will see. Other than that, art is probably my greatest weakness, though I will probably buy quite a bit of what I need if I ever reach that point.
Yeah, I hear you. I’m powering through dozens of Blender tutorials at the moment. That’s one of the reason I’m working on another smaller project as well. A simple game that uses very primitive graphics, so I can learn the entire content develompent pipeline. For a project as ambitious as your own, you should seriously consider teaming up with an artist later on, and first focus on making the game work with programmer art.
Yeah if I can find an artist with the ability and the time, but that can be hard. I won’t really look for an artist until I can complete most major systems and that may be a couple years away.
Speaking of blender tutorials, have you seen a good one for creating UV maps? I found one that seemed good but was beyond my level even though all I need to do is map to a hexagon. I may create a swamp tile soon and may as well fix the rest of my tiles if I can work out how to properly align a texture to a mesh.
On another note, integrating the river system with randomly sized lakes is a fair bit more complicated than I first imagined. That and my brain has been work-fatigued lately.
So I have taken to generating an outline of the the general flow of execution using comments before I actually put the bits and pieces together. This is different from my normal approach of creating a function, then the next, etc and then going back and filling in things I missed. I just drop a string of comment boxes in the general order of execution and then I can fill out each box as I get ideas on how they should be implemented. The best part of creating such outlines is I can rearrange the order and put things in the middle before things get all stringed together.
Thanks! I watched the first video while eating and I think I already have a better understanding. I will bookmark it and come back to it when I go to work on the tiles.
Finally got the rivers to exit the lakes at random points. Given how complex this turned out to be, it was really hard to stay focused since I didn’t have any solid, non-distracted blocks of time to work on it. That and there were some bugs that would pop up one in a dozen map generations that were really annoying to track down.
Green = River dumping into lake.
Blue = River exiting lake.
Yellow = River dumping into ocean.
Here is the blueprint before I melt it down into functions and macros:
I will probably keep it like this for awhile as I iron out a few more potential bugs and add a few more features to the system.
Going forward I will be working on generating swamps for river/lake systems that do not properly drain into an ocean or larger body of water. I will also create a fresh water array and then track which tiles have access to a river, lake, or wet tile for future game systems.
I cant believe how far this has come, its looking absolutely amazing and is really starting to look like youre generating a planets worth of habitat Im really liking the rivers, I dont blame you for getting abit of brain melt, this is alot more complicated than it looks on the surface so Im glad you got past those little devils and got the rivers working
+1 MonsOlympus : Really great work and happy for you that you got those bugs ! Continue to show, please. I don’t speak a lot but i regularly come and it is really inspirating for my own generated levels system too.
So the above starts with 1 tile index from map in the Open List. Then I neighbor check his 6 neighbors and each neighbor sharing a tile type gets added to the open list. This continues until each like tile in the landmass or body of water is put into the closed list. When that is complete I dump the closed list into an array and add 100,000 multiplied by the multiplier. The multiplier starts at 1 and increments by 1 every time the closed list gets dumped. So the first lake would have tiles that look like 1XX,XXX, the second 2XX,XXX, etc. The reason I use 100,000 is because the upper range for map indexes is over 10,000, and the highest number is what I use to track which lake I am looking at.
With each lake serialized into an array I need a way to retrieve that information:
I have Current Index which is whatever tile I want to look at. I go through my entire Water Body Array, divide it by the 100,000, and match the remainder to my Current Index. Then I know I have the right lake, so I set that to the Current Landmass/Body of Water for use in:
Since I now know what lake I am looking for, I use that info to pull all the tiles of that lake from the Water Body Array and dump them into my Lake Array.
Its not a problem, thank you so much for sharing so many of the details of your work with us all, it really helps the community more than you know
My projects are okay, Ive been taking some time out to get some formal programming qualifications so I havent had time to progress with any more with hex field generation. I do have some ideas, inspired by your work in this thread I may pursue and I can certainly make myself available if you get stuck and see another pair of eyes or hands Multi-dimensional arrays is something Ive always been interested in personally and there are methods in C++ that arnt exposed to the Blueprints I think its TMap but there are a few options there and even in blueprint you’d really have to know the specifics to use it effectively which could be why Epic opted to leave it out, similar to quats.
I have been thinking about taking some classes as well, but with kids and a full time job there isn’t much time left in the day. Could definitely use something more focused in Blender/GIMP/etc, as you can see below from my failure to create UVs after following multiple tutorials…
So I remembered as I was writing this that you can put arrays in structs and then those structs into arrays. So I updated my system to use that instead. Can’t tell the difference performance-wise, but probably the better way to do things.
Here I have implemented a basic Marsh generator:
Any given lake only has one river exiting it, but can have multiple entering it. If a river exits a lake and re-enters it, then I generate Marsh around the lake and the river that is looping back into it.
I think I will create a lowland generator so that if a river passes near a lowland, the lowland is next to a lake/ocean, or the lowland tile is Wet, then it would naturally form a Marsh. Lowlands will only apply to plains tiles. Then I can tie lowland generation to a map setting so players can play with the global marsh coverage as they like. Also, I may work out some Marsh Forests.
Lowland generator working and modifiable in the map settings. Here is a hellish swamp world:
If a tile is plains, is also a lowland, and has access to a coast, river, or wet precipitation, then it becomes a Marsh.
Will probably create a Marsh Forest mesh based on the current Jungle meshes. Marshes in hotter zones will have vegetation, while colder climates will have less or none.
Actually, maybe I will just have the Jungles spawn over the marshes in the warmer latitudes. That makes sense anyway and saves me on the extra meshes/tile types.
Here is one with low Swamps and Elevation added back in:
Haven’t run with elevation on in awhile just because it was easier to test the rivers without them.