I want to write some algorithms to identify possible locations for towns. This is a fork of mapgen2.
Ingredients:
- calculate slope at every point (but isn’t this uniform?) → it was indeed uniform in mapgen2, and useless, but might be useful in other generator
- identify arable land (low slope, good moisture) → using the biome as a proxy for this, but might be different in other generators
- identify fresh water access (rivers) → waterdistance_r == 0 (water distance is to the nearest river)
- exclude beaches, lakes, oceans → using the biome
- for each candidate town location:
- use dijkstra’s algorithm within some range to see what’s “reachable”
- use variable movement costs (depend on biome, discourage crossing rivers, encourage following roads, etc.)
- towns want ≥1 fresh water, ≥2 arable tiles (later: build farms and assign them to towns, so another town can’t use the same farm)
- rank the candidates somehow, and place a town at the top spot (for now, put towns everywhere they can be)
- build roads between towns, but roads can’t go across large rivers
- build the next town, repeat a few times
Caveats:
- mapgen2 maps aren’t varied enough (mountain locations, slopes, rivers) to test how well this algorithm works with a different terrain generator
- so far it seems like this kind of algorithm requires a lot of tweaking to balance the different factors for town and road placement
Improvements:
- maybe build villages first before placing towns, because it seems like there aren’t enough towns
- or try all-pairs shortest paths to provide bonuses for town placement
- all existing actually used paths should be factored in as bonuses for future town placement
- ocean harbors should be factored in as bonuses for town placement too