one thing you could use to generate the maps is order 1 makov chain
if you dont know what map generated order 1 makov chain is:
you would basically create a good map(s)
then you would split it into a square grid.
then you would get the statistics of map (what is the % of quares that have water…)
then you also get neighbour statistics (what are the things usually adjacent to a water tile???)
to generate the map you generate a random tile at random based on how likely it is to a tile be of a specific type.
Then you generate adjacent tiles at random based on how likely it is to a tile be adjacent to a tile of that type.
Important thing 1:
A square tile is adjacent to 4 tiles (up down, left and right [or 8 if you count diagonals]), a important thing is to create a generation pattern that most of the time you will be generating square tiles with alot of already generated adjacent square tiles.
As some example if you generate square tiles of the first row from left to right, then of the second row from left to right, then the third… you will generate a X pattern.
A way that could fix that, is generate a random square and then generate a random square between the ones with the most amount of already generated adjacent squares, then again generate a random square between the ones with most amount of already generated squares.
Important thing 2:
As you see this could generate maps with less than the amount of towns wanted or with different towns than the wanted ones. There are 2 ways to solve the problem
More literal one and one that takes more time:
Generate map until one dont come with this problem.
Before generating the map put the cities at random places. And then you continue to generate the map from this.