Package worldBuilder

Class TerritoryEngine


  • public class TerritoryEngine
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      TerritoryEngine​(Map map)
      MeshPoints are grouped into territories, based on what city they are closest too (not in km, but in travel days).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort()
      fall back to the previously saved set of routes
      void allCities()
      find all known cities and add all of their neighbors to the queue to be explored.
      void commit()
      commit the current set of routes
      double cost​(int from, int to)
      compute the cost of traveling from one point to a neighbor
      TradeRoute outwards​(int needed, boolean ocean_too)
      Journey outwards from each city until we have covered the map.
      void reset()
      discard all records of previous expansions to enable new point-to-point routes
      void set_parms​(double t_flat, double t_climb, double t_cross, double min_per_day, double max_days)
      update the parameters that guide route selection
      boolean startFrom​(int point)
      add a new point to the list from which we expand outwards
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TerritoryEngine

        public TerritoryEngine​(Map map)
        MeshPoints are grouped into territories, based on what city they are closest too (not in km, but in travel days). This Engine starts from all of the cities and travels out until it encounters the border (equal travel to either city). This approach is taken from O'Leary, though w/different computations
    • Method Detail

      • allCities

        public void allCities()
        find all known cities and add all of their neighbors to the queue to be explored.
      • reset

        public void reset()
        discard all records of previous expansions to enable new point-to-point routes
      • startFrom

        public boolean startFrom​(int point)
        add a new point to the list from which we expand outwards
        Parameters:
        point - index of point
      • outwards

        public TradeRoute outwards​(int needed,
                                   boolean ocean_too)
        Journey outwards from each city until we have covered the map. When we reach a MeshPoint already covered from another city, record it as a possible trade route.
        Parameters:
        needed - ... maximum number of routes to generate
        ocean_too - ... do we want paths to the ocean
      • cost

        public double cost​(int from,
                           int to)
        compute the cost of traveling from one point to a neighbor
        Parameters:
        from - origin point
        to - destination point
        Returns:
        travel time (in days)
      • set_parms

        public void set_parms​(double t_flat,
                              double t_climb,
                              double t_cross,
                              double min_per_day,
                              double max_days)
        update the parameters that guide route selection
        Parameters:
        t_flat - minutes to travel one flat km
        t_climb - minutes to gain 1000 meters
        t_cross - minutes to cross a 1M^3/s stream
        min_per_day - minutes of travel per day
        max_days - maximum days between cities
      • commit

        public void commit()
        commit the current set of routes
      • abort

        public void abort()
        fall back to the previously saved set of routes