patchFreeciv - Patches: patch #3903, Don't use UMT_SEA to assign...

Show feedback again

patch #3903: Don't use UMT_SEA to assign unknown_MC cost

Submitted by:  Emmet Hikory <persia>
Submitted on:  Wed May 8 11:38:14 2013  
Category: aiPriority: 5 - Normal
Status: DonePrivacy: Public
Assigned to: pepeto <pepeto>Open/Closed: Closed
Planned Release: 2.6.0Contains string changes: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

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


Mon Feb 3 19:45:55 2014, SVN revision 24335:

Pathfinding unknown movement cost is more ruleset-flexible:

  • The cost is equal to the highest movement cost the unit can encounter.
  • A malus (mutliplied by 2) is applied if a unit cannot enter all terrains.
  • UTYF_IGTER is now handled.
  • The value is now cached by unit type.

Patch by Emmet Hikory (persia@gna) and me

See patch #3903

(Browse SVN revision 24335)

pepeto <pepeto>
Project MemberIn charge of this item.
Wed Jan 29 21:46:09 2014, comment #4:

Noticed I have uploaded 3 times wrong files. Attempting to attach the right one...

(file #19892)

pepeto <pepeto>
Project MemberIn charge of this item.
Mon Jan 27 15:05:41 2014, comment #3:

New version of the patch: after discussion for bug #21535, UTYF_IGTER flag is tested only for UCF_TERRAIN_SPEED units.

(file #19874)

pepeto <pepeto>
Project MemberIn charge of this item.
Wed Jan 22 23:22:56 2014, comment #2:

After reading the discussion for rt PR#6977, I understand that the calculation of unknown_MC has been wanted to be the highest possible cost for a unit. This value is multiplied by 2 if the unit can encounter unsuitable terrains. This is what my patch does.

But I see in the implementation (SVN revision 10719) two errors:

  1. it totally ignore if unit has UTYF_IGTER or not.
pepeto <pepeto>
Project MemberIn charge of this item.
Tue Jan 21 19:01:06 2014, comment #1:

How could I get the discussion of PR#6977?

(file #19811)

pepeto <pepeto>
Project MemberIn charge of this item.
Wed May 8 11:38:14 2013, original submission:

From what I can glean from incomplete archives of discussion surrounding PR #6977 preceeding SVN revision 10719, the rationale behind the code that led to the comment "Sailing units explore less" in pf_tools.c is that units that don't respect terrain speed should have unknown_MC larger than their normal move because they might try to go somewhere they can't go, so UMT_SEA units should have unknown_MC of 2*SINGLE_MOVE and UMT_BOTH units should have unknown_MC of SINGLE_MOVE. This represents an assumption that all sailing units are !UCF_TERRAIN_SPEED and an assumption that all UMT_BOTH units have unrestricted nativity.

The attached patch addresses those assumptions by iterating through the terrains for the !UCF_TERRAIN_SPEED case, and only setting unknown_MC to 2*SINGLE_MOVE in the event some terrain is not native. For classical units, this represents no difference. Specific differences for other units are:

1) UCF_TERRAIN_SPEED units that are UMT_SEA now are charged 2 * movement_cost for the most awkward native terrain, rather than 2 * SINGLE_MOVE.

2) units that are neither UCF_TERRAIN_SPEED nor UMT_SEA are now charged 2 * SINGLE_MOVE if there exist any terrains not native to the unit, rather than SINGLE_MOVE.

In both cases, the value of unknown_MC should be larger than before, so non-classical units with additional restrictions (e.g. seagoing units that respect terrain speed or amphibious non-mountaineering units) may be less likely to plot paths through unknown terrain.

As mentioned in the original discussion, it might make sense to set values for unknown_MC based on unit class once, and use these cached values when constructing pathfinding maps, rather than recalculating the value every time a parameter is defined. These may even be interesting to ruleset authors, who might want to express something like "Merchant units never find paths through unknown tiles" or "Intercontinental Missiles care nothing about the underlying surface". That said, implementation of these is well beyond the scope of the current patch.

Emmet Hikory <persia>
Project Member


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

Attach File(s):

Attached Files
file #19892:  pf_unkown_MC.diff added by pepeto (6kB - text/x-diff)
file #17928:  native-unknown_MC.patch added by persia (2kB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by pepeto (Updated the item)
  • -unavailable- added by persia (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.


    Error: not logged in



    Follow 14 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Feb 3 19:46:22 2014pepetoStatusReady For Test=>Done
    Wed Jan 29 21:46:09 2014pepetoAttached File-=>Added pf_unkown_MC.diff, #19892
    Wed Jan 29 21:38:19 2014pepetoAttached File#19874=>Removed
    Mon Jan 27 15:05:41 2014pepetoAttached File-=>Added text_pf_unkown_MC, #19874
    Mon Jan 27 14:57:34 2014pepetoAttached File#19823=>Removed
    Wed Jan 22 23:22:56 2014pepetoAttached File-=>Added text_pf_unkown_MC, #19823
      StatusIn Progress=>Ready For Test
    Tue Jan 21 19:01:16 2014pepetoAttached File#19811=>Removed
    Tue Jan 21 19:01:06 2014pepetoAttached File-=>Added pf_unkown_MC.diff, #19811
      StatusNone=>In Progress
      Planned Release=>2.6.0
    Wed Jan 8 12:42:29 2014pepetoAssigned toNone=>pepeto
    Wed May 8 11:38:14 2013persiaAttached File-=>Added native-unknown_MC.patch, #17928
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup