Some people here seem to be proposing some quite complicated ways to try and generate the basic layout of the roads. Trading routes? I'm not a programmer, but I know a
bit about some of the stuff. So I thought I'd share my idea to generate the roads.
(that probably sucks)
This is obviously an imperfect solution that would need huge refinement. Either way, to me at least, it seems achievable (maybe?). The basic road layouts would be generated in advance, and would likely need to be re-generated for mods that alter the heightmap. This would all use the
A* algorithm, with each ~800x800m world chunk being a node.
The generation would start with large cities (>=32 blocks?), then go to smaller towns (>=16 blocks?), then down to the smallest (<16 chunks?). Any roads generated from this would be one of three qualities / sizes, this would be based of which of the previous categories of cities it would be.
After the cities it would move on to taverns, then farms, then houses, these would have even smaller and worse quality roads.
At each of the previous steps, it would look for the nearest 3(? maybe 1 or 2 for smaller locations?) locations of
higher tier (or equal for the largest cities), and use the A* algorithm to try and link to each, starting with the furthest away first, assuming there wasn't already a road connecting them, remember, each ~800x800m "chuck" of the world would be a different node.
Difficulty to move to each different node would depend on several things;
1) Incline of slope (the higher the harder)
2) If the node is already a larger road (make it easier, intended to simulate the road joining up, then separating again), in other words, "meeting up" and temporarily joining with other larger only(?) roads. As can be seen in the following image, this smaller road from the farm joins with the larger one between the towns up to get to the destinations.
- using_roads.png (44.18 KiB) Viewed 4114 times
3) If the node contains a location, e.g. a tavern or home, not dungeons(?) (makes it actually take away "movement points"(or whatever the technical term is). It makes sense to make a small deviation to a resting place for travellers, does it not?). This is helpful in situations such as the one below, where it's only a small detour from sentinel to the tavern.
- sentinel_road.png (956 Bytes) Viewed 4114 times
4) If it's water (making them impassible / making them bridges and very hard)
Issues (that I can think of):
-The big one: This is only for the vague layout, not anything at the actual game level, just the world. This could be addressed by increasing the "resolution" of nodes, e.g. having 4, 16, or even 64 in each "chunk". Even after that you would still have many issues, lining up the roads with the city gates for example.
-Making the roads avoid dungeons might be a tricky thing to do, and could make the shape of the roads very unnatural. However dungeons don't necessarily have to be avoided.
-In that one kingdom containing that "river", in reality a bridge would be built, this does not simulate this. You could make water chunks traversable to get around this, however you would have to limit in to large roads only, and somehow make a sectioned models of bridges to chuck together.
-Some chunks might have more height variation in them than others, this could produce strange results.