Maybe you could add something that the AI always tries to build roads in all 5 directions coming out of headquarters/warehouses, before placing any buildings near them? And then leave them there, even if the flags are unconnected at first.
this won't do much, but it's a good idea. certainly useful. could be implemented
- 3 steps roads - I am not sure if we can find out before placing the road how it can be split by flags. I see the code: map[c].nodecaps() & BUILDCAPS_FLAG but I am not sure if the nodecaps are or are not changed by placing a road. If we can know it before actual placing the road. Moreover, sometimes 3 step roads are probably necessary.. [emphasis mine]
that's the crux of the issue. when you have mostlly flat land and a large map, you absolutely want to avoid 3 steps roads. transportation is going to be a nightmare, and you need everything you can to keep it streamlined. It's worth sacrificing a few building spaces for it. And it's definitely worth making a road slightly longer, for example if you have a 3 step distance you make a curved road to have 4 steps and be able to split them in segments of 2.
But, on the other hand, when you have a small map and rugged terrain, then you need every building space you can scrape up, and 3 steps roads aren't an issue, because you don't have enough traffic for it to be a problem.
And if you have large but rugged land, you make a few major highways that are always 2 steps and as straight as possible, and then you make all kinds of smaller roads where you don't care much.
A skilled human would know in advance the rough shape of the map. Even if one went completely blind, one may start with cramped roads, and then once he sees the map is getting bigger and transportation is getting messier he would straighten the roads at the cost of dismantling several buildings.
AI doesn't try a map first, but AI starts with the map scouted. we can use this feature.
Perhaps we could have the program count the total amount of buildable space in the map and divide it by the number of players, giving a measure of how much land every player can expect. The higher this number, the more the AI will try to avoid 3 steps roads; the smaller the number, the more the AI will try to salvage as many building sites as possible.
Another option is to program the AI to recognize major directions and make major highways. A major direction is the shortest route between two distant large plots of buildable land. On this major direction a major highway will be built, and it will be a road that must be relatively straight and it must not have any 3 steps road. Problem with this is that those are all fuzzy human concepts.
I can play ice wars as bllue and immediatey see that I want a highway going from the middle straigh nort-east, with another NE-SW highway every screen or so, and a series of east-west highways also every screen or so, and a single SE-NW highway in the middle because it takes away space for buildings. And I can also recognize that the best way to make that SE-NW highway is for it to overlap the central mountain, because that way I'll still be able to get all the ores under the road, and i will lose less valuable building space. while on two frontiers I want a single highway going around the island, or maybe two highways, one on the inner and one on the outer side of the ring. But how the hell do I translate this into algorithms?