URL:
  <http://gna.org/patch/?3820>

                 Summary: Avoid selecting RMM_RELAXED roads when they are less
good
                 Project: Freeciv
            Submitted by: persia
            Submitted on: Sun 31 Mar 2013 09:42:26 AM GMT
                Category: general
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 

    _______________________________________________________

Details:

Depending on the order of road_type_iterate, it is possible for the move cost
in tile_move_cost_ptrs() to select 2*relaxed-road-cost in preference to
1*other-road-cost.  If the RMM_RELAXED road has a move_cost of 2 and the other
road has a move_cost of 3, this is suboptimal.

A test example is to define "Mountain Track" as a move_cost=3 road that may
only be built on mountains, and "River" as a move_cost=2 road that operates
under RMM_RELAXED.

This is trivally fixed by verifying road_cost > proad->move_cost*2 in the
RMM_RELAXED case, but when making this change, there were some other things
about tile_move_cost_ptrs() that seemed worth adjusting while I was there, as
follows:

1) Don't check nativity of t2 with two different calls, but rather reuse the
cached boolean "native" when testing for slow_invasions

2) Don't recalculate the class of the unit twice (once in
unit_type_class(unit_type(punit)) and once with unit_class(punit)) when
setting local cache variables: instead use pclass directly to determine
nativity.

3) Don't track separately "cost" and "road_cost" values, when there is only
interest in roads that provide benefits (which also allows dropping the MAX()
test at the end of the function)

4) Don't bother checking for a positive road_cost value when preinitialising
with the base terrain movement cost.

    For rulesets where all RMM_RELAXED roads have move_cost of 1, or where all
roads have move_cost < 3, this patch should have no effect whatsoever.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Sun 31 Mar 2013 09:42:26 AM GMT  Name:
avoid-selecting-bad-relaxed-road.patch  Size: 4kB   By: persia

<http://gna.org/patch/download.php?file_id=17623>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/patch/?3820>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to