AI road logic

KungCheops

Warlord
Joined
Mar 23, 2011
Messages
158
Location
Sweden
Hello!

I find myself constantly mildly infuriated with AI road building logic and wanted to try and write new logic for this.
The thing is I've never modded before and don't really know where to start on this so it would be nice with some pointers.

Also, is this something that would be appreciated? Do you guys feel like this has been worked on as much as the tools allow?

Some things that I wonder if they would be possible are:
  • calculating paths including harbors
  • future city planning
  • removing suboptimal old roads and building new ones
Thanks in advance!
 
Since we are on this topic, is there a way of automating workers to remove old roads built by AI near captured cities that no longer goes anywhere but is costing heaps of upkeep simply because they are now within my border?
 
what exactly is bothering you?

- pathfinding is rather well optimized by now. check CvAStar. for road building in particular CvBuilderTaskingAI::UpdateRoutePlots() is also relevant.

- city site selection is also quite ok, although it only looks at single sites at a time (no recursive logic like: the best site is here, but if i move it a bit i could squeeze in another city over there ...).

- removing old roads is not implemented. hard to tell what is a useful road and what is not.
 
To clarify my points a bit, what I meant with city planning was if it would be possible to make roads with future cities in mind. As in when a road can go south or east, it could look at possibilities for cities to the south or to the east.

My point with harbors was really that I don't think the ai should ever build roads that are 20+ tiles long to a single city. I'd rather see it wait until it has a nearby city with a harbor to connect it (or a city in between the city and the rest of the empire). I just realized that this doesn't really have all that much to do with harbors. Mainly just wasting gold on insanely long roads.

And regarding removal of old roads. Is road pathfinding logic ignorant of other cities when building between two? In that case could this possibly be changed? Otherwise I think it should be possible to calculate new road networks from scratch and rebuilding them.


P.s. where are the files to look at?
 
It doesn't seem like it would be too difficult to put some very basic city planning in though. Something as simple as "I need a road south-east or south-west to connect an existing city, am I more likely to build a city to the east or west in the future?".
 
It doesn't seem like it would be too difficult to put some very basic city planning in though. Something as simple as "I need a road south-east or south-west to connect an existing city, am I more likely to build a city to the east or west in the future?".

That's putting thousands and thousands of lines of code very simply.

G
 
Top Bottom