Sitrus wrote: ↑Wed Dec 04, 2019 12:55 pm
Local minima is in this the closest neighbor, i.e. connect first only cities that are closest to each other. It makes the roads make more sense and drops the amount of computation required. It should also drop the level of error for making nonsensical roads trying to cross the sea or lakes.
I think the terrain could just be smoothed. if you know the path that is calculated, just smooth the area based on the left and right heights of the road. If there's a slope, you just start iterating from one side at height n by n-1 until you reach the othersides height. if they're on the same plane or similar planes, smooth them to the same level. I would start with this and see what it does, then start calculating a slope of the sides by a logaritmic curve or sth else. Then smooth out the path forward using a peek forward (so you peek to see the height of the map for the next 10 meters, to decide do you start to make the road rise or go lower).
I have some time for this if you need help, I can mostly stab at it in C++/C or Python if that is any help. I understand the terrain generation can be altered? Is there a guide for that, I think I could whip up a proof of concept for the algorithm quite quick actually if it's relatively simple to setup.
I just realised this after posting, but for the traffic generation to decide the size of the road. I don't think that's a good idea to try and aim for immediately, first handle the path finding and get that working to some degree. After that it would be easier to start working on the traffic, most likely by assigning a weight based on the classification of the city. I.e. if it's a capital or an actual town, assign a higher weight. Weight determines the width and material of the road.
I'm still pretty new to this and in the middle of reworking the terrain sampler while learning a lot in the process. The way you describe it, it'd be a pass after the terrain for the map pixel has been generated. What I had in mind would try to integrate it into the generation process.
Some background information about the terrain generation:
Each map pixel is 800x800 meters
128x128 samples are generated to create the random terrain
This makes each sample 6.25x6.25 meters
Using a list of sample coordinates that will be used for road, it should be possible to flatten out terrain for roads while also allowing some sloping to occur on the edges. The road weight would determine if it's 1, 2, 3 or however many tiles wide.
This way, it's generated in one go, later on when terrain texturing is done, it can just refer to the list of sample coordinates to determine if it's a road or not.
If you setup Unity and download the DFU github repo, you can play around with the default terrain sampler and see how it works. I can probably answer most questions you have about it. DFU and Unity use C# so you shouldn't have much of an issue coming to grips with it, I've never coded any C# before I got dragged into this.
I agree with starting simple but connecting the main cities in a region (or in a smaller controlled area) seems a better starting point to me but the approach is still the same.