patchFreeciv - Patches: patch #4639, Autosettler support for...

Show feedback again

patch #4639: Autosettler support for integrating roads.

Submitted by:  Marko Lindqvist <cazfi>
Submitted on:  Tue 01 Apr 2014 10:02:46 PM UTC  
Category: aiPriority: 5 - Normal
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Planned Release: 2.6.0

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Sun 13 Apr 2014 09:23:00 AM UTC, comment #3:

That depends on what is considered a regression. While it would be better than what is in place now, it would not be as good as what was in place before integrating roads. For purposes of example, let us categorize paths for simplicity into "road" and "railroad", where "road" is a dependency of "railroad", and different terrains have different values of "road" and "railroad", and all "road" paths integrate, and all "railroad" paths integrate (which is handy because it grants per-terrain build-time without using a single hardcoded per-terrain road_time value). So, in the event that a autosettler is considering a path that has no continuous adjacent terrain, failure to consider the dependencies of an integrating road will differ from the pre-integration behaviour (because potential_road[] would be false, as the "road" for the starting terrain would neither integrate nor be a dependency for a "railroad" under consideration).

I've been thinking about this more, and suspect that the algorithm is no longer able to handle the flexibility of the current ruleset definitions. As another example, assume there are two kinds of road, "road" and "railroad", which do not integrate, if "road" may be built on any TC_LAND terrain, and "railroad" may be built on any non-mountainous terrain that has a "road", the current algorithm will grant overly large bonus for building railroads near mountains, as it will never notice this is impossible (or maybe the example is less complicated if one can't put railroads in jungles, because of the interaction with production bonuses).

Also, with complex nativity, and road nativity, there are other factors involved in generating connectivity: if a settler could build either roads or canals, where roads were slightly faster for some unit classes, and canals provided native movement to other unit classes that were previously non-native to the tile, which is better?

Although it does provide a regression, perhaps something like the following makes sense as a replacement (ignoring caching optimisation, etc).

Iterate over all tiles adjacent to the given tile
Iterate over all roads integrating with the given road
If the integration road can ever be built on the iteration tile,
If any dependency road of the iteration road exists on the iteration tile
OR any dependency road of the iteration road is being built there
Iterate over all unit classes
/*target tiles are adjacent to given tile and non-adjacent to iteration tile*/
If creating the given road on the given tile allows a unit class to
reach a target tile better/faster
increment the bonus
multiply the bonus by a magic number (3 seems reasonable)
divide the bonus by the number of unit classes in the ruleset

This should handle the nativity situation (the magic number is used to reduce the number of bonuses that fall to zero because of unaffected units (e.g. sea/air). As a bonus it clears up the messy undocumented mess (with some apparent transcription mistakes) that is the current guidance model.

A more advanced solution would somehow use pathfinding to determine whether adding the given road to the given tile generally improves transportation flexibility for that player's units (to reduce e.g. 0-cost path loops, etc.), but that probably belongs in another ticket (and may represent unacceptable computational cost).

Emmet Hikory <persia>
Project Member
Sun 13 Apr 2014 06:46:25 AM UTC, comment #2:

The simplest one ("consider any existing integrating road as interesting for the purposes of a link") already avoids regressions if some ruleset is updated to have different road types for different terrains (the main use-case I see for integrating roads).

Marko Lindqvist <cazfi>
Project Administrator
Wed 02 Apr 2014 07:12:53 PM UTC, comment #1:

So, this function mostly considers whether putting a given road on a tile will help connectivity between adjacent tiles. When doing so, it considers that if any dependency of the road being considered is present on a potential source tile, that the road under consideration may as well be on the potential source tile (as it is considered underway), which helps autosettlers build more advanced roads.

There are two possible ways to treat integrating roads. The simple one is to consider any existing integrating road as interesting for the purposes of a link. The more complex is to consider any dependency road of an integrating road as interesting.

There is also the question of whether the move cost of an integrating road should be considered: in the case where there are integrating roads of differing move costs, it may be interesting for autosettlers to receive a greater bonus for building the faster of the integrating roads, which may require refactoring of settler_evaluate_improvements() and tai_city_worker_requests_create().

Suggestions on the strategy for implementation appreciated.

Emmet Hikory <persia>
Project Member
Tue 01 Apr 2014 10:02:46 PM UTC, original submission:

Integrating roads should be considered when autosettler plans road networks in adv_settlers_road_bonus()

Marko Lindqvist <cazfi>
Project Administrator


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by persia (Posted a comment)
  • -unavailable- added by cazfi (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    No Changes Have Been Made to This Item
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup