Class CustomDijkstraMap

java.lang.Object
squidpony.squidai.CustomDijkstraMap
All Implemented Interfaces:
Serializable

public class CustomDijkstraMap
extends Object
implements Serializable
An alternative to AStarSearch when you want to fully explore a search space, or when you want a gradient floodfill, with customizable rules for what is considered adjacent. This can be used for games where rotation matters (and possibly costs movement), for games with thin walls (where a wall between cells prevents travel between those two cells even if the wall doesn't occupy a walkable cell), for games where the edges between cells may have some requisite to travel across, like a vertical amount that must be hopped up or down between cells, and for games that have portals between distant cells on the same map.
As a bit of introduction, the article http://www.roguebasin.com/index.php?title=Dijkstra_Maps_Visualized can provide some useful information on how these work and how to visualize the information they can produce, while http://www.roguebasin.com/index.php?title=The_Incredible_Power_of_Dijkstra_Maps is an inspiring list of the various features Dijkstra Maps can enable.
If you can't remember how to spell this, just remember: Does It Just Know Stuff? That's Really Awesome! Created by Tommy Ettinger on 4/4/2015.
See Also:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    Adjacency adjacency
    The main factor in determining the "Custom" behavior of CustomDijkstraMap; using an Adjacency implementation like Adjacency.BasicAdjacency should cause this class to mimic DijkstraMap, but using Adjacency.RotationAdjacency will be very different.
    int[] costMap
    This stores the type of each cell for the purposes of determining its cost to enter; in most cases this type is the char used to represent the cell, but any int can be used if you need more information.
    static double DARK
    This is used to mark cells that the scan couldn't reach, and these dark cells are marked with a high number equal to 999800 .
    static double FLOOR
    Floor cells, which include any walkable cell, are marked with a high number equal to 999200 .
    protected IntVLA fresh  
    static double GOAL
    Goals are always marked with 0.
    protected IntVLA goals  
    double[] gradientMap
    The frequently-changing values that are often the point of using this class; goals will have a value of 0, and any cells that can have a character reach a goal in n steps will have a value of n.
    int height
    Height of the map.
    int[][][] neighbors
    The neighbors map, as produced by adjacency; can be modified by passing neighbors as the first argument to Adjacency.portal(int[][][], int, int, boolean) if you want to create portals between non-adjacent cells.
    IntVLA path
    The latest path that was obtained by calling findPath().
    double[] physicalMap
    Stores which parts of the map are accessible and which are not.
    IRNG rng
    The RNG used to decide which one of multiple equally-short paths to take.
    static double WALL
    Walls, which are solid no-entry cells, are marked with a high number equal to 999500 .
    int width
    Width of the map.
  • Constructor Summary

    Constructors 
    Constructor Description
    CustomDijkstraMap()
    Construct a CustomDijkstraMap without a level to actually scan.
    CustomDijkstraMap​(char[][] level)
    Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other char[][] where '#' means a wall and anything else is a walkable tile.
    CustomDijkstraMap​(char[][] level, char alternateWall)
    Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other char[][] where one char means a wall and anything else is a walkable tile.
    CustomDijkstraMap​(char[][] level, Adjacency adjacency)
    Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other char[][] where '#' means a wall and anything else is a walkable tile.
    CustomDijkstraMap​(char[][] level, Adjacency adjacency, IRNG rng)
    Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other char[][] where '#' means a wall and anything else is a walkable tile.
    CustomDijkstraMap​(char[][] level, IRNG rng)
    Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other char[][] where '#' means a wall and anything else is a walkable tile.
    CustomDijkstraMap​(double[] level, int width, int height)
    Used to construct a CustomDijkstraMap from the output of another.
    CustomDijkstraMap​(double[] level, Adjacency adjacency)
    Used to construct a CustomDijkstraMap from the output of another, specifying a distance calculation.
    CustomDijkstraMap​(IRNG random)
    Construct a CustomDijkstraMap without a level to actually scan.
  • Method Summary

    Modifier and Type Method Description
    void clearGoals()
    Used to remove all goals and undo any changes to gradientMap made by having a goal present.
    IntVLA findFleePath​(int length, double preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... fearSources)
    Scans the dungeon using CustomDijkstraMap.scan with the listed fearSources and start point, and returns a list of Coord positions (using Manhattan distance) needed to get further from the closest fearSources, meant for running away.
    IntVLA findFleePath​(int length, int scanLimit, double preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... fearSources)
    Scans the dungeon using CustomDijkstraMap.scan with the listed fearSources and start point, and returns a list of Coord positions (using Manhattan distance) needed to get further from the closest fearSources, meant for running away.
    IntVLA findFleePathLarge​(int size, int length, int scanLimit, int preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... fearSources)
    Scans the dungeon using CustomDijkstraMap.scanLarge with the listed fearSources and start point, and returns a list of Coord positions (using Manhattan distance) needed to get further from the closest fearSources, meant for running away.
    IntVLA findFleePathLarge​(int size, int length, int preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... fearSources)
    Scans the dungeon using CustomDijkstraMap.scanLarge with the listed fearSources and start point, and returns a list of Coord positions (using Manhattan distance) needed to get further from the closest fearSources, meant for running away.
    static Measurement findMeasurement​(Radius radius)
    Gets the appropriate DijkstraMap.Measurement to pass to a constructor if you already have a Radius.
    IntVLA findPath​(int length, int scanLimit, IntVLA impassable, IntVLA onlyPassable, int start, int... targets)
    Scans the dungeon using CustomDijkstraMap.scan with the listed goals and start point, and returns a list of Coord positions (using the current measurement) needed to get closer to the closest reachable goal.
    IntVLA findPath​(int length, IntVLA impassable, IntVLA onlyPassable, int start, int... targets)
    Scans the dungeon using CustomDijkstraMap.scan with the listed goals and start point, and returns a list of Coord positions (using the current measurement) needed to get closer to the closest reachable goal.
    IntVLA findPathLarge​(int size, int length, int scanLimit, IntVLA impassable, IntVLA onlyPassable, int start, int... targets)
    Scans the dungeon using CustomDijkstraMap.scanLarge with the listed goals and start point, and returns a list of Coord positions (using the current measurement) needed to get closer to the closest reachable goal.
    IntVLA findPathLarge​(int size, int length, IntVLA impassable, IntVLA onlyPassable, int start, int... targets)
    Scans the dungeon using CustomDijkstraMap.scan with the listed goals and start point, and returns a list of Coord positions (using the current measurement) needed to get closer to the closest reachable goal.
    static Radius findRadius​(Measurement measurement)
    Gets the appropriate Radius corresponding to a DijkstraMap.Measurement.
    IntDoubleOrderedMap floodFill​(int radius, int... starts)
    A simple limited flood-fill that returns a OrderedMap of Coord keys to the Double values in the CustomDijkstraMap, only calculating out to a number of steps determined by limit.
    int getMappedCount()  
    CustomDijkstraMap initialize​(char[][] level)
    Used to initialize or re-initialize a CustomDijkstraMap that needs a new PhysicalMap because it either wasn't given one when it was constructed, or because the contents of the terrain have changed permanently (not if a creature moved; for that you pass the positions of creatures that block paths to scan() or findPath() ).
    CustomDijkstraMap initialize​(char[][] level, char alternateWall)
    Used to initialize or re-initialize a CustomDijkstraMap that needs a new PhysicalMap because it either wasn't given one when it was constructed, or because the contents of the terrain have changed permanently (not if a creature moved; for that you pass the positions of creatures that block paths to scan() or findPath() ).
    CustomDijkstraMap initialize​(double[] level)
    Used to initialize or re-initialize a CustomDijkstraMap that needs a new PhysicalMap because it either wasn't given one when it was constructed, or because the contents of the terrain have changed permanently (not if a creature moved; for that you pass the positions of creatures that block paths to scan() or findPath() ).
    CustomDijkstraMap initializeCost​(char[][] level)
    Used to initialize the entry cost modifiers for games that require variable costs to enter squares.
    CustomDijkstraMap initializeCost​(int[] tiles)
    Used to initialize the entry cost modifiers for games that require variable costs to enter squares.
    boolean isBlocked​(int start, int direction)  
    double[] partialScan​(int limit, int usable, int[] impassable)
    Recalculate the CustomDijkstra map up to a limit and return it.
    double[] partialScan​(int limit, IntVLA impassable)
    Recalculate the CustomDijkstra map up to a limit and return it.
    protected void partialScanInternal​(int start, int limit, int[] impassable, int usable)  
    double[] partialScanLarge​(int size, int limit, int usable, int[] impassable)
    Recalculate the CustomDijkstra map for a creature that is potentially larger than 1x1 cell and return it.
    double[] partialScanLarge​(int size, int limit, IntVLA impassable)
    Recalculate the CustomDijkstra map, up to a limit, for a creature that is potentially larger than 1x1 cell and return it.
    protected void partialScanLargeInternal​(int start, int size, int limit, int[] impassable, int usable)  
    double[] partialScanToStart​(int limit, int start, int usable, int[] impassable)
    Recalculate the CustomDijkstra map up to a limit, stopping early if it has a path from a goal to start, and return it.
    double[] partialScanToStart​(int limit, int start, IntVLA impassable)
    Recalculate the CustomDijkstra map up to a limit, stopping early if it has a path from a goal to start, and return that map.
    double[] partialScanToStartLarge​(int size, int limit, int start, int usable, int[] impassable)
    Recalculate the CustomDijkstra map, up to a limit, for a creature that is potentially larger than 1x1 cell, stopping early if a path is found between a goal and start, and return that map.
    double[] partialScanToStartLarge​(int size, int limit, int start, IntVLA impassable)
    Recalculate the CustomDijkstra map, up to a limit, for a creature that is potentially larger than 1x1 cell, stopping early if a path is found between a goal and start, and return that map.
    void reset()
    Resets this CustomDijkstraMap to a state with no goals, no discovered path, and no changes made to gradientMap relative to physicalMap.
    void resetCell​(int pt)
    Reverts a cell to the value stored in the original state of the level as known by physicalMap.
    void resetMap()
    Resets the gradientMap to its original value from physicalMap.
    double[] scan​(int usable, int[] impassable)
    Recalculate the CustomDijkstra map and return it.
    double[] scan​(IntVLA impassable)
    Recalculate the CustomDijkstra map and return it.
    protected void scanInternal​(int start, int[] impassable, int usable)  
    double[] scanLarge​(int size, int usable, int[] impassable)
    Recalculate the CustomDijkstra map for a creature that is potentially larger than 1x1 cell and return it.
    double[] scanLarge​(int size, IntVLA impassable)
    Recalculate the CustomDijkstra map for a creature that is potentially larger than 1x1 cell and return it.
    protected void scanLargeInternal​(int start, int size, int[] impassable, int usable)  
    double[] scanToStart​(int start, int usable, int[] impassable)
    Recalculate the CustomDijkstra map, stopping early if it has a path from a goal to start, and return that map.
    double[] scanToStart​(int start, IntVLA impassable)
    Recalculate the CustomDijkstra map, stopping early if it has a path from a goal to start, and return that map.
    double[] scanToStartLarge​(int size, int start, int usable, int[] impassable)
    Recalculate the CustomDijkstra map for a creature that is potentially larger than 1x1 cell and return it.
    double[] scanToStartLarge​(int size, int start, IntVLA impassable)
    Recalculate the CustomDijkstra map for a creature that is potentially larger than 1x1 cell and return it.
    void setCost​(int pt, int tile)
    Marks a cell's type for pathfinding cost as tile (it still will look up the tile in the Adjacency.costRules field of adjacency when it tries to move through one), unless the cell is a wall or unreachable area (then it always sets the cost to a value that should have the same cost as a wall).
    protected void setFresh​(int pt, double counter)  
    void setGoal​(int pt)
    Marks a cell as a goal for pathfinding, unless the cell is a wall or unreachable area (then it does nothing).
    void setOccupied​(int pt)
    Marks a specific cell in gradientMap as completely impossible to enter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • adjacency

      The main factor in determining the "Custom" behavior of CustomDijkstraMap; using an Adjacency implementation like Adjacency.BasicAdjacency should cause this class to mimic DijkstraMap, but using Adjacency.RotationAdjacency will be very different.
    • physicalMap

      public double[] physicalMap
      Stores which parts of the map are accessible and which are not. Should not be changed unless the actual physical terrain has changed. You should call initialize() with a new map instead of changing this directly.
    • gradientMap

      public double[] gradientMap
      The frequently-changing values that are often the point of using this class; goals will have a value of 0, and any cells that can have a character reach a goal in n steps will have a value of n. Cells that cannot be entered because they are solid will have a very high value equal to the WALL constant in this class, and cells that cannot be entered because they cannot reach a goal will have a different very high value equal to the DARK constant in this class.
    • costMap

      public int[] costMap
      This stores the type of each cell for the purposes of determining its cost to enter; in most cases this type is the char used to represent the cell, but any int can be used if you need more information. An int from costMap is looked up in Adjacency.costRules to get the actual cost as a double; this collection should almost always start with a reasonable default value for when the int key is not present. It's common to simply assign a char like '#' or '.' to an element in costMap.
    • neighbors

      public int[][][] neighbors
      The neighbors map, as produced by adjacency; can be modified by passing neighbors as the first argument to Adjacency.portal(int[][][], int, int, boolean) if you want to create portals between non-adjacent cells.
    • height

      public int height
      Height of the map. Exciting stuff. Don't change this, instead call initialize().
    • width

      public int width
      Width of the map. Exciting stuff. Don't change this, instead call initialize().
    • path

      public IntVLA path
      The latest path that was obtained by calling findPath(). It will not contain the value passed as a starting cell; only steps that require movement will be included, and so if the path has not been found or a valid path toward a goal is impossible, this ArrayList will be empty.
    • GOAL

      public static final double GOAL
      Goals are always marked with 0.
      See Also:
      Constant Field Values
    • FLOOR

      public static final double FLOOR
      Floor cells, which include any walkable cell, are marked with a high number equal to 999200 .
      See Also:
      Constant Field Values
    • WALL

      public static final double WALL
      Walls, which are solid no-entry cells, are marked with a high number equal to 999500 .
      See Also:
      Constant Field Values
    • DARK

      public static final double DARK
      This is used to mark cells that the scan couldn't reach, and these dark cells are marked with a high number equal to 999800 .
      See Also:
      Constant Field Values
    • goals

      protected IntVLA goals
    • fresh

      protected IntVLA fresh
    • rng

      public IRNG rng
      The RNG used to decide which one of multiple equally-short paths to take.
  • Constructor Details

    • CustomDijkstraMap

      Construct a CustomDijkstraMap without a level to actually scan. If you use this constructor, you must call an initialize() method before using this class.
    • CustomDijkstraMap

      public CustomDijkstraMap​(IRNG random)
      Construct a CustomDijkstraMap without a level to actually scan. This constructor allows you to specify an RNG before it is ever used in this class. If you use this constructor, you must call an initialize() method before using any other methods in the class.
    • CustomDijkstraMap

      public CustomDijkstraMap​(double[] level, int width, int height)
      Used to construct a CustomDijkstraMap from the output of another.
      Parameters:
      level -
    • CustomDijkstraMap

      public CustomDijkstraMap​(double[] level, Adjacency adjacency)
      Used to construct a CustomDijkstraMap from the output of another, specifying a distance calculation.
      Parameters:
      level -
      adjacency -
    • CustomDijkstraMap

      public CustomDijkstraMap​(char[][] level)
      Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other char[][] where '#' means a wall and anything else is a walkable tile. If you only have a map that uses box-drawing characters, use DungeonUtility.linesToHashes() to get a map that can be used here.
      Parameters:
      level -
    • CustomDijkstraMap

      public CustomDijkstraMap​(char[][] level, IRNG rng)
      Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other char[][] where '#' means a wall and anything else is a walkable tile. If you only have a map that uses box-drawing characters, use DungeonUtility.linesToHashes() to get a map that can be used here. Also takes an RNG that ensures predictable path choices given otherwise identical inputs and circumstances.
      Parameters:
      level -
      rng - The RNG to use for certain decisions; only affects find* methods like findPath, not scan.
    • CustomDijkstraMap

      public CustomDijkstraMap​(char[][] level, char alternateWall)
      Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other char[][] where one char means a wall and anything else is a walkable tile. If you only have a map that uses box-drawing characters, use DungeonUtility.linesToHashes() to get a map that can be used here. You can specify the character used for walls.
      Parameters:
      level -
    • CustomDijkstraMap

      public CustomDijkstraMap​(char[][] level, Adjacency adjacency)
      Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other char[][] where '#' means a wall and anything else is a walkable tile. If you only have a map that uses box-drawing characters, use DungeonUtility.linesToHashes() to get a map that can be used here. This constructor specifies a distance measurement.
      Parameters:
      level -
      adjacency -
    • CustomDijkstraMap

      public CustomDijkstraMap​(char[][] level, Adjacency adjacency, IRNG rng)
      Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other char[][] where '#' means a wall and anything else is a walkable tile. If you only have a map that uses box-drawing characters, use DungeonUtility.linesToHashes() to get a map that can be used here. Also takes a distance measurement and an IRNG that can be seeded to ensure predictable path choices given otherwise identical inputs and circumstances.
      Parameters:
      level -
      rng - The IRNG, such as an RNG, to use for certain decisions; only affects find* methods like findPath, not scan.
  • Method Details

    • initialize

      public CustomDijkstraMap initialize​(double[] level)
      Used to initialize or re-initialize a CustomDijkstraMap that needs a new PhysicalMap because it either wasn't given one when it was constructed, or because the contents of the terrain have changed permanently (not if a creature moved; for that you pass the positions of creatures that block paths to scan() or findPath() ).
      Parameters:
      level -
      Returns:
    • initialize

      public CustomDijkstraMap initialize​(char[][] level)
      Used to initialize or re-initialize a CustomDijkstraMap that needs a new PhysicalMap because it either wasn't given one when it was constructed, or because the contents of the terrain have changed permanently (not if a creature moved; for that you pass the positions of creatures that block paths to scan() or findPath() ).
      Parameters:
      level -
      Returns:
    • initialize

      public CustomDijkstraMap initialize​(char[][] level, char alternateWall)
      Used to initialize or re-initialize a CustomDijkstraMap that needs a new PhysicalMap because it either wasn't given one when it was constructed, or because the contents of the terrain have changed permanently (not if a creature moved; for that you pass the positions of creatures that block paths to scan() or findPath() ). This initialize() method allows you to specify an alternate wall char other than the default character, '#' .
      Parameters:
      level -
      alternateWall -
      Returns:
    • initializeCost

      public CustomDijkstraMap initializeCost​(char[][] level)
      Used to initialize the entry cost modifiers for games that require variable costs to enter squares. This expects a char[][] of the same exact dimensions as the 2D array that was used to previously initialize() this CustomDijkstraMap, treating the '#' char as a wall (impassable) and anything else as having a normal cost to enter. The costs can be accessed later by using costMap directly (which will have a valid value when this does not throw an exception), or by calling setCost().
      Parameters:
      level - a 2D char array that uses '#' for walls
      Returns:
      this CustomDijkstraMap for chaining.
    • initializeCost

      public CustomDijkstraMap initializeCost​(int[] tiles)
      Used to initialize the entry cost modifiers for games that require variable costs to enter squares. This expects an int[] with length equal to the length of any inner array of neighbors (a field that is given a value during initialize() by this object's Adjacency value), using the int corresponding to a location as the tile type to look up for that location, as a key in Adjacency.costRules, even if an int isn't what this class would assign normally -- although, walls and other impassable values should be given '#' (which can be put in an int array) or the value of alternateWall, if this was given one, as a value. The tiles can be accessed later by using costMap directly (which will have a valid value when this does not throw an exception), or by calling setCost().

      This method should be slightly more efficient than the other initializeCost methods.

      Parameters:
      tiles - an int array that already has tile types that adjacency can find values for
      Returns:
      this CustomDijkstraMap for chaining.
    • findMeasurement

      public static Measurement findMeasurement​(Radius radius)
      Gets the appropriate DijkstraMap.Measurement to pass to a constructor if you already have a Radius. Matches SQUARE or CUBE to CHEBYSHEV, DIAMOND or OCTAHEDRON to MANHATTAN, and CIRCLE or SPHERE to EUCLIDEAN.
      Parameters:
      radius - the Radius to find the corresponding Measurement for
      Returns:
      a DijkstraMap.Measurement that matches radius; SQUARE to CHEBYSHEV, DIAMOND to MANHATTAN, etc.
    • findRadius

      public static Radius findRadius​(Measurement measurement)
      Gets the appropriate Radius corresponding to a DijkstraMap.Measurement. Matches CHEBYSHEV to SQUARE, MANHATTAN to DIAMOND, and EUCLIDEAN to CIRCLE.
      Parameters:
      measurement - the Measurement to find the corresponding Radius for
      Returns:
      a DijkstraMap.Measurement that matches radius; CHEBYSHEV to SQUARE, MANHATTAN to DIAMOND, etc.
    • resetMap

      public void resetMap()
      Resets the gradientMap to its original value from physicalMap.
    • reset

      public void reset()
      Resets this CustomDijkstraMap to a state with no goals, no discovered path, and no changes made to gradientMap relative to physicalMap.
    • setGoal

      public void setGoal​(int pt)
      Marks a cell as a goal for pathfinding, unless the cell is a wall or unreachable area (then it does nothing).
      Parameters:
      pt -
    • setCost

      public void setCost​(int pt, int tile)
      Marks a cell's type for pathfinding cost as tile (it still will look up the tile in the Adjacency.costRules field of adjacency when it tries to move through one), unless the cell is a wall or unreachable area (then it always sets the cost to a value that should have the same cost as a wall). The normal usage of this is something like setCost(position, '.') for maps without rotation (this sets the cost of moving into the cell position to the cost of entering a floor marked with '.'; thos is looked up in the Adjacency's cost rules and those can be set with Adjacency.addCostRule(char, double)). If the map has rotation, setCost(position, '.' | 0x10000) will change the cost to turn while standing on a tile to the cost of turning on a '.' floor, though this is just one way Adjacency can be implemented (it's how RotationAdjacency works).
      Parameters:
      pt - the encoded position/rotation/height to set the cost for
      tile - typically a char such as '.' for floors, but if this uses rotation, turns on that tile are different
    • setOccupied

      public void setOccupied​(int pt)
      Marks a specific cell in gradientMap as completely impossible to enter.
      Parameters:
      pt -
    • resetCell

      public void resetCell​(int pt)
      Reverts a cell to the value stored in the original state of the level as known by physicalMap.
      Parameters:
      pt -
    • clearGoals

      public void clearGoals()
      Used to remove all goals and undo any changes to gradientMap made by having a goal present.
    • setFresh

      protected void setFresh​(int pt, double counter)
    • isBlocked

      public boolean isBlocked​(int start, int direction)
    • scan

      public double[] scan​(int usable, int[] impassable)
      Recalculate the CustomDijkstra map and return it. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Parameters:
      usable - how much of impassable to actually use; should usually be equal to impassable.length, but can be anything if impassable is null (then, it is ignored). This exists to differentiate this method from the overload that takes an IntVLA when that argument is null, but also to give some flexibility.
      impassable - An array of int keys (encoded by an Adjacency, usually) representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null (meaning no obstacles).
      Returns:
      An int array using the dimensions of what this knows about the physical map.
    • scan

      public double[] scan​(IntVLA impassable)
      Recalculate the CustomDijkstra map and return it. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Parameters:
      impassable - An array of int keys (encoded by an Adjacency, usually) representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null (meaning no obstacles).
      Returns:
      An int array using the dimensions of what this knows about the physical map.
    • scanToStart

      public double[] scanToStart​(int start, int usable, int[] impassable)
      Recalculate the CustomDijkstra map, stopping early if it has a path from a goal to start, and return that map. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Parameters:
      start - the encoded index of the start of the pathfinder; when this has a path from goal to start, it ends
      usable - how much of impassable to actually use; should usually be equal to impassable.length, but can be anything if impassable is null (then, it is ignored). This exists to differentiate this method from the overload that takes an IntVLA when that argument is null, but also to give some flexibility.
      impassable - An array of int keys (encoded by an Adjacency, usually) representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null (meaning no obstacles).
      Returns:
      An int array using the dimensions of what this knows about the physical map.
    • scanToStart

      public double[] scanToStart​(int start, IntVLA impassable)
      Recalculate the CustomDijkstra map, stopping early if it has a path from a goal to start, and return that map. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Parameters:
      start - the encoded index of the start of the pathfinder; when this has a path from goal to start, it ends
      impassable - An array of int keys (encoded by an Adjacency, usually) representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null (meaning no obstacles).
      Returns:
      An int array using the dimensions of what this knows about the physical map.
    • scanInternal

      protected void scanInternal​(int start, int[] impassable, int usable)
    • partialScan

      public double[] partialScan​(int limit, int usable, int[] impassable)
      Recalculate the CustomDijkstra map up to a limit and return it. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. If a cell would take more steps to reach than the given limit, it will have a value of DARK if it was passable instead of the distance. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class. This uses the current measurement.
      Parameters:
      limit - The maximum number of steps to scan outward from a goal.
      usable - how much of impassable to actually use; should usually be equal to impassable.length, but can be anything if impassable is null (then, it is ignored). This exists to differentiate this method from the overload that takes an IntVLA when that argument is null, but also to give some flexibility.
      impassable - An array or vararg of int keys representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null if there are no such obstacles.
      Returns:
      A int array using the dimensions of what this knows about the physical map.
    • partialScan

      public double[] partialScan​(int limit, IntVLA impassable)
      Recalculate the CustomDijkstra map up to a limit and return it. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. If a cell would take more steps to reach than the given limit, it will have a value of DARK if it was passable instead of the distance. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class. This uses the current measurement.
      Parameters:
      limit - The maximum number of steps to scan outward from a goal.
      impassable - An IntVLA of int keys representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null if there are no such obstacles.
      Returns:
      A int array using the dimensions of what this knows about the physical map.
    • partialScanToStart

      public double[] partialScanToStart​(int limit, int start, int usable, int[] impassable)
      Recalculate the CustomDijkstra map up to a limit, stopping early if it has a path from a goal to start, and return it. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Parameters:
      start - the encoded index of the start of the pathfinder; when this has a path from goal to start, it ends
      limit - The maximum number of steps to scan outward from a goal.
      usable - how much of impassable to actually use; should usually be equal to impassable.length, but can be anything if impassable is null (then, it is ignored). This exists to differentiate this method from the overload that takes an IntVLA when that argument is null, but also to give some flexibility.
      impassable - An array of int keys (encoded by an Adjacency, usually) representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null (meaning no obstacles).
      Returns:
      An int array using the dimensions of what this knows about the physical map.
    • partialScanToStart

      public double[] partialScanToStart​(int limit, int start, IntVLA impassable)
      Recalculate the CustomDijkstra map up to a limit, stopping early if it has a path from a goal to start, and return that map. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Parameters:
      start - the encoded index of the start of the pathfinder; when this has a path from goal to start, it ends
      limit - The maximum number of steps to scan outward from a goal.
      impassable - An array of int keys (encoded by an Adjacency, usually) representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null (meaning no obstacles).
      Returns:
      An int array using the dimensions of what this knows about the physical map.
    • partialScanInternal

      protected void partialScanInternal​(int start, int limit, int[] impassable, int usable)
    • scanLarge

      public double[] scanLarge​(int size, int usable, int[] impassable)
      Recalculate the CustomDijkstra map for a creature that is potentially larger than 1x1 cell and return it. The value of a cell in the returned CustomDijkstra map assumes that a creature is square, with a side length equal to the passed size, that its minimum-x, minimum-y cell is the starting cell, and that any cell with a distance number represents the distance for the creature's minimum-x, minimum-y cell to reach it. Cells that cannot be entered by the minimum-x, minimum-y cell because of sizing (such as a floor cell next to a maximum-x and/or maximum-y wall if size is > 1) will be marked as DARK. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class. (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Portals and wrapping are not currently recommended in conjunction with multi-square creatures, since a 2x2 creature could easily occupy two cells on the east edge and two cells on the west edge of the map, and that poses all sorts of issues for creatures trying to pathfind to it, not to mention the more general issues of how to display a bisected, but mobile, creature.
      Parameters:
      size - The length of one side of a square creature using this to find a path, i.e. 2 for a 2x2 cell creature. Non-square creatures are not supported because turning is really hard.
      usable - how much of impassable to actually use; should usually be equal to impassable.length, but can be anything if impassable is null (then, it is ignored). This exists to differentiate this method from the overload that takes an IntVLA when that argument is null, but also to give some flexibility.
      impassable - An array of encoded int keys representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null if there are no such obstacles.
      Returns:
      An int array using the dimensions/rotations of what this knows about the physical map.
    • scanLarge

      public double[] scanLarge​(int size, IntVLA impassable)
      Recalculate the CustomDijkstra map for a creature that is potentially larger than 1x1 cell and return it. The value of a cell in the returned CustomDijkstra map assumes that a creature is square, with a side length equal to the passed size, that its minimum-x, minimum-y cell is the starting cell, and that any cell with a distance number represents the distance for the creature's minimum-x, minimum-y cell to reach it. Cells that cannot be entered by the minimum-x, minimum-y cell because of sizing (such as a floor cell next to a maximum-x and/or maximum-y wall if size is > 1) will be marked as DARK. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class. (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Portals and wrapping are not currently recommended in conjunction with multi-square creatures, since a 2x2 creature could easily occupy two cells on the east edge and two cells on the west edge of the map, and that poses all sorts of issues for creatures trying to pathfind to it, not to mention the more general issues of how to display a bisected, but mobile, creature.
      Parameters:
      size - The length of one side of a square creature using this to find a path, i.e. 2 for a 2x2 cell creature. Non-square creatures are not supported because turning is really hard.
      impassable - An IntVLA where items are ints representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null if there are no such obstacles.
      Returns:
      A 2D int[width][height] using the width and height of what this knows about the physical map.
    • scanToStartLarge

      public double[] scanToStartLarge​(int size, int start, int usable, int[] impassable)
      Recalculate the CustomDijkstra map for a creature that is potentially larger than 1x1 cell and return it. The value of a cell in the returned CustomDijkstra map assumes that a creature is square, with a side length equal to the passed size, that its minimum-x, minimum-y cell is the starting cell, and that any cell with a distance number represents the distance for the creature's minimum-x, minimum-y cell to reach it. Cells that cannot be entered by the minimum-x, minimum-y cell because of sizing (such as a floor cell next to a maximum-x and/or maximum-y wall if size is > 1) will be marked as DARK. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class. (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Portals and wrapping are not currently recommended in conjunction with multi-square creatures, since a 2x2 creature could easily occupy two cells on the east edge and two cells on the west edge of the map, and that poses all sorts of issues for creatures trying to pathfind to it, not to mention the more general issues of how to display a bisected, but mobile, creature.
      Parameters:
      size - The length of one side of a square creature using this to find a path, i.e. 2 for a 2x2 cell creature. Non-square creatures are not supported because turning is really hard.
      start - the encoded index of the start of the pathfinder; when this has a path from goal to start, it ends
      usable - how much of impassable to actually use; should usually be equal to impassable.length, but can be anything if impassable is null (then, it is ignored). This exists to differentiate this method from the overload that takes an IntVLA when that argument is null, but also to give some flexibility.
      impassable - An array of encoded int keys representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null if there are no such obstacles.
      Returns:
      An int array using the dimensions/rotations of what this knows about the physical map.
    • scanToStartLarge

      public double[] scanToStartLarge​(int size, int start, IntVLA impassable)
      Recalculate the CustomDijkstra map for a creature that is potentially larger than 1x1 cell and return it. The value of a cell in the returned CustomDijkstra map assumes that a creature is square, with a side length equal to the passed size, that its minimum-x, minimum-y cell is the starting cell, and that any cell with a distance number represents the distance for the creature's minimum-x, minimum-y cell to reach it. Cells that cannot be entered by the minimum-x, minimum-y cell because of sizing (such as a floor cell next to a maximum-x and/or maximum-y wall if size is > 1) will be marked as DARK. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class. (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Portals and wrapping are not currently recommended in conjunction with multi-square creatures, since a 2x2 creature could easily occupy two cells on the east edge and two cells on the west edge of the map, and that poses all sorts of issues for creatures trying to pathfind to it, not to mention the more general issues of how to display a bisected, but mobile, creature.
      Parameters:
      size - The length of one side of a square creature using this to find a path, i.e. 2 for a 2x2 cell creature. Non-square creatures are not supported because turning is really hard.
      start - the encoded index of the start of the pathfinder; when this has a path from goal to start, it ends
      impassable - An IntVLA where items are ints representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null if there are no such obstacles.
      Returns:
      A 2D int[width][height] using the width and height of what this knows about the physical map.
    • scanLargeInternal

      protected void scanLargeInternal​(int start, int size, int[] impassable, int usable)
    • partialScanLarge

      public double[] partialScanLarge​(int size, int limit, int usable, int[] impassable)
      Recalculate the CustomDijkstra map for a creature that is potentially larger than 1x1 cell and return it. The value of a cell in the returned CustomDijkstra map assumes that a creature is square, with a side length equal to the passed size, that its minimum-x, minimum-y cell is the starting cell, and that any cell with a distance number represents the distance for the creature's minimum-x, minimum-y cell to reach it. Cells that cannot be entered by the minimum-x, minimum-y cell because of sizing (such as a floor cell next to a maximum-x and/or maximum-y wall if size is > 1) will be marked as DARK. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class. (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Portals and wrapping are not currently recommended in conjunction with multi-square creatures, since a 2x2 creature could easily occupy two cells on the east edge and two cells on the west edge of the map, and that poses all sorts of issues for creatures trying to pathfind to it, not to mention the more general issues of how to display a bisected, but mobile, creature.
      Parameters:
      size - The length of one side of a square creature using this to find a path, i.e. 2 for a 2x2 cell creature. Non-square creatures are not supported because turning is really hard.
      limit - The maximum number of steps to scan outward from a goal.
      usable - how much of impassable to actually use; should usually be equal to impassable.length, but can be anything if impassable is null (then, it is ignored). This exists to differentiate this method from the overload that takes an IntVLA when that argument is null, but also to give some flexibility.
      impassable - An array of encoded int keys representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null if there are no such obstacles.
      Returns:
      A 2D int[width][height] using the width and height of what this knows about the physical map.
    • partialScanLarge

      public double[] partialScanLarge​(int size, int limit, IntVLA impassable)
      Recalculate the CustomDijkstra map, up to a limit, for a creature that is potentially larger than 1x1 cell and return it. The value of a cell in the returned CustomDijkstra map assumes that a creature is square, with a side length equal to the passed size, that its minimum-x, minimum-y cell is the starting cell, and that any cell with a distance number represents the distance for the creature's minimum-x, minimum-y cell to reach it. Cells that cannot be entered by the minimum-x, minimum-y cell because of sizing (such as a floor cell next to a maximum-x and/or maximum-y wall if size is > 1) will be marked as DARK. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class. (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Portals and wrapping are not currently recommended in conjunction with multi-square creatures, since a 2x2 creature could easily occupy two cells on the east edge and two cells on the west edge of the map, and that poses all sorts of issues for creatures trying to pathfind to it, not to mention the more general issues of how to display a bisected, but mobile, creature.
      Parameters:
      size - The length of one side of a square creature using this to find a path, i.e. 2 for a 2x2 cell creature. Non-square creatures are not supported because turning is really hard.
      limit - The maximum number of steps to scan outward from a goal.
      impassable - An IntVLA where items are ints representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null if there are no such obstacles.
      Returns:
      A 2D int[width][height] using the width and height of what this knows about the physical map.
    • partialScanToStartLarge

      public double[] partialScanToStartLarge​(int size, int limit, int start, int usable, int[] impassable)
      Recalculate the CustomDijkstra map, up to a limit, for a creature that is potentially larger than 1x1 cell, stopping early if a path is found between a goal and start, and return that map. The value of a cell in the returned CustomDijkstra map assumes that a creature is square, with a side length equal to the passed size, that its minimum-x, minimum-y cell is the starting cell, and that any cell with a distance number represents the distance for the creature's minimum-x, minimum-y cell to reach it. Cells that cannot be entered by the minimum-x, minimum-y cell because of sizing (such as a floor cell next to a maximum-x and/or maximum-y wall if size is > 1) will be marked as DARK. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class. (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Portals and wrapping are not currently recommended in conjunction with multi-square creatures, since a 2x2 creature could easily occupy two cells on the east edge and two cells on the west edge of the map, and that poses all sorts of issues for creatures trying to pathfind to it, not to mention the more general issues of how to display a bisected, but mobile, creature.
      Parameters:
      size - The length of one side of a square creature using this to find a path, i.e. 2 for a 2x2 cell creature. Non-square creatures are not supported because turning is really hard.
      limit - The maximum number of steps to scan outward from a goal.
      start - the encoded index of the start of the pathfinder; when this has a path from goal to start, it ends
      usable - how much of impassable to actually use; should usually be equal to impassable.length, but can be anything if impassable is null (then, it is ignored). This exists to differentiate this method from the overload that takes an IntVLA when that argument is null, but also to give some flexibility.
      impassable - An array of encoded int keys representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null if there are no such obstacles.
      Returns:
      An int array using the dimensions/rotations of what this knows about the physical map.
    • partialScanToStartLarge

      public double[] partialScanToStartLarge​(int size, int limit, int start, IntVLA impassable)
      Recalculate the CustomDijkstra map, up to a limit, for a creature that is potentially larger than 1x1 cell, stopping early if a path is found between a goal and start, and return that map. The value of a cell in the returned CustomDijkstra map assumes that a creature is square, with a side length equal to the passed size, that its minimum-x, minimum-y cell is the starting cell, and that any cell with a distance number represents the distance for the creature's minimum-x, minimum-y cell to reach it. Cells that cannot be entered by the minimum-x, minimum-y cell because of sizing (such as a floor cell next to a maximum-x and/or maximum-y wall if size is > 1) will be marked as DARK. Cells that were marked as goals with setGoal will have a value of 0, the cells adjacent to goals will have a value of 1, and cells progressively further from goals will have a value equal to the distance from the nearest goal. The exceptions are walls, which will have a value defined by the WALL constant in this class, and areas that the scan was unable to reach, which will have a value defined by the DARK constant in this class. (typically, these areas should not be used to place NPCs or items and should be filled with walls). This uses the current measurement.
      Portals and wrapping are not currently recommended in conjunction with multi-square creatures, since a 2x2 creature could easily occupy two cells on the east edge and two cells on the west edge of the map, and that poses all sorts of issues for creatures trying to pathfind to it, not to mention the more general issues of how to display a bisected, but mobile, creature.
      Parameters:
      size - The length of one side of a square creature using this to find a path, i.e. 2 for a 2x2 cell creature. Non-square creatures are not supported because turning is really hard.
      limit - The maximum number of steps to scan outward from a goal.
      start - the encoded index of the start of the pathfinder; when this has a path from goal to start, it ends
      impassable - An IntVLA where items are ints representing the locations of enemies or other moving obstacles to a path that cannot be moved through; this can be null if there are no such obstacles.
      Returns:
      A 2D int[width][height] using the width and height of what this knows about the physical map.
    • partialScanLargeInternal

      protected void partialScanLargeInternal​(int start, int size, int limit, int[] impassable, int usable)
    • findPath

      public IntVLA findPath​(int length, IntVLA impassable, IntVLA onlyPassable, int start, int... targets)
      Scans the dungeon using CustomDijkstraMap.scan with the listed goals and start point, and returns a list of Coord positions (using the current measurement) needed to get closer to the closest reachable goal. The maximum length of the returned list is given by length; if moving the full length of the list would place the mover in a position shared by one of the positions in onlyPassable (which is typically filled with friendly units that can be passed through in multi-tile- movement scenarios), it will recalculate a move so that it does not pass into that cell. The keys in impassable should be the positions of enemies and obstacles that cannot be moved through, and will be ignored if there is a goal overlapping one.
      This caches its result in a member field, path, which can be fetched after finding a path and will change with each call to a pathfinding method.
      Parameters:
      length - the length of the path to calculate
      impassable - a Set of impassable Coord positions that may change (not constant like walls); can be null
      onlyPassable - a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be null
      start - the start of the path, should correspond to the minimum-x, minimum-y position of the pathfinder
      targets - a vararg or array of Coord that this will try to pathfind toward
      Returns:
      an ArrayList of Coord that will contain the locations of this creature as it goes toward a target. Copy of path.
    • findPath

      public IntVLA findPath​(int length, int scanLimit, IntVLA impassable, IntVLA onlyPassable, int start, int... targets)
      Scans the dungeon using CustomDijkstraMap.scan with the listed goals and start point, and returns a list of Coord positions (using the current measurement) needed to get closer to the closest reachable goal. The maximum length of the returned list is given by length; if moving the full length of the list would place the mover in a position shared by one of the positions in onlyPassable (which is typically filled with friendly units that can be passed through in multi-tile- movement scenarios), it will recalculate a move so that it does not pass into that cell. The keys in impassable should be the positions of enemies and obstacles that cannot be moved through, and will be ignored if there is a goal overlapping one.
      This caches its result in a member field, path, which can be fetched after finding a path and will change with each call to a pathfinding method.
      Parameters:
      length - the length of the path to calculate
      impassable - a Set of impassable Coord positions that may change (not constant like walls); can be null
      onlyPassable - a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be null
      start - the start of the path, should correspond to the minimum-x, minimum-y position of the pathfinder
      targets - a vararg or array of Coord that this will try to pathfind toward
      Returns:
      an ArrayList of Coord that will contain the locations of this creature as it goes toward a target. Copy of path.
    • findFleePath

      public IntVLA findFleePath​(int length, double preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... fearSources)
      Scans the dungeon using CustomDijkstraMap.scan with the listed fearSources and start point, and returns a list of Coord positions (using Manhattan distance) needed to get further from the closest fearSources, meant for running away. The maximum length of the returned list is given by length; if moving the full length of the list would place the mover in a position shared by one of the positions in onlyPassable (which is typically filled with friendly units that can be passed through in multi-tile- movement scenarios), it will recalculate a move so that it does not pass into that cell. The keys in impassable should be the positions of enemies and obstacles that cannot be moved through, and will be ignored if there is a fearSource overlapping one. The preferLongerPaths parameter is meant to be tweaked and adjusted; higher values should make creatures prefer to escape out of doorways instead of hiding in the closest corner, and a value of 1.2 should be typical for many maps. The parameters preferLongerPaths, impassable, and the varargs used for fearSources will be cached, and any subsequent calls that use the same values as the last values passed will avoid recalculating unnecessary scans.
      This caches its result in a member field, path, which can be fetched after finding a path and will change with each call to a pathfinding method.
      Parameters:
      length - the length of the path to calculate
      preferLongerPaths - Set this to 1.2 if you aren't sure; it will probably need tweaking for different maps.
      impassable - a Set of impassable Coord positions that may change (not constant like walls); can be null
      onlyPassable - a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be null
      start - the start of the path, should correspond to the minimum-x, minimum-y position of the pathfinder
      fearSources - a vararg or array of Coord positions to run away from
      Returns:
      an ArrayList of Coord that will contain the locations of this creature as it goes away from fear sources. Copy of path.
    • findFleePath

      public IntVLA findFleePath​(int length, int scanLimit, double preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... fearSources)
      Scans the dungeon using CustomDijkstraMap.scan with the listed fearSources and start point, and returns a list of Coord positions (using Manhattan distance) needed to get further from the closest fearSources, meant for running away. The maximum length of the returned list is given by length; if moving the full length of the list would place the mover in a position shared by one of the positions in onlyPassable (which is typically filled with friendly units that can be passed through in multi-tile- movement scenarios), it will recalculate a move so that it does not pass into that cell. The keys in impassable should be the positions of enemies and obstacles that cannot be moved through, and will be ignored if there is a fearSource overlapping one. The preferLongerPaths parameter is meant to be tweaked and adjusted; higher values should make creatures prefer to escape out of doorways instead of hiding in the closest corner, and a value of 1.2 should be typical for many maps. The parameters preferLongerPaths, impassable, and the varargs used for fearSources will be cached, and any subsequent calls that use the same values as the last values passed will avoid recalculating unnecessary scans.
      This caches its result in a member field, path, which can be fetched after finding a path and will change with each call to a pathfinding method.
      Parameters:
      length - the length of the path to calculate
      scanLimit - how many steps away from a fear source to calculate; negative scans the whole map
      preferLongerPaths - Set this to 1.2 if you aren't sure; it will probably need tweaking for different maps.
      impassable - a Set of impassable Coord positions that may change (not constant like walls); can be null
      onlyPassable - a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be null
      start - the start of the path, should correspond to the minimum-x, minimum-y position of the pathfinder
      fearSources - a vararg or array of Coord positions to run away from
      Returns:
      an ArrayList of Coord that will contain the locations of this creature as it goes away from fear sources. Copy of path.
    • findPathLarge

      public IntVLA findPathLarge​(int size, int length, IntVLA impassable, IntVLA onlyPassable, int start, int... targets)
      Scans the dungeon using CustomDijkstraMap.scan with the listed goals and start point, and returns a list of Coord positions (using the current measurement) needed to get closer to the closest reachable goal. The maximum length of the returned list is given by length; if moving the full length of the list would place the mover in a position shared by one of the positions in onlyPassable (which is typically filled with friendly units that can be passed through in multi-tile- movement scenarios), it will recalculate a move so that it does not pass into that cell. The keys in impassable should be the positions of enemies and obstacles that cannot be moved through, and will be ignored if there is a goal overlapping one. The parameter size refers to the side length of a square unit, such as 2 for a 2x2 unit. The parameter start must refer to the minimum-x, minimum-y cell of that unit if size is > 1, and all positions in the returned path will refer to movement of the minimum-x, minimum-y cell.
      This caches its result in a member field, path, which can be fetched after finding a path and will change with each call to a pathfinding method.
      Parameters:
      size - the side length of the creature trying to find a path
      length - the length of the path to calculate
      impassable - a Set of impassable Coord positions that may change (not constant like walls); can be null
      onlyPassable - a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be null
      start - the start of the path, should correspond to the minimum-x, minimum-y position of the pathfinder
      targets - a vararg or array of Coord that this will try to pathfind toward
      Returns:
      an ArrayList of Coord that will contain the min-x, min-y locations of this creature as it goes toward a target. Copy of path.
    • findPathLarge

      public IntVLA findPathLarge​(int size, int length, int scanLimit, IntVLA impassable, IntVLA onlyPassable, int start, int... targets)
      Scans the dungeon using CustomDijkstraMap.scanLarge with the listed goals and start point, and returns a list of Coord positions (using the current measurement) needed to get closer to the closest reachable goal. The maximum length of the returned list is given by length; if moving the full length of the list would place the mover in a position shared by one of the positions in onlyPassable (which is typically filled with friendly units that can be passed through in multi-tile- movement scenarios), it will recalculate a move so that it does not pass into that cell. The keys in impassable should be the positions of enemies and obstacles that cannot be moved through, and will be ignored if there is a goal overlapping one. The parameter size refers to the side length of a square unit, such as 2 for a 2x2 unit. The parameter start must refer to the minimum-x, minimum-y cell of that unit if size is > 1, and all positions in the returned path will refer to movement of the minimum-x, minimum-y cell.
      This caches its result in a member field, path, which can be fetched after finding a path and will change with each call to a pathfinding method.
      Parameters:
      size - the side length of the creature trying to find a path
      length - the length of the path to calculate
      scanLimit - how many steps away from a goal to calculate; negative scans the whole map
      impassable - a Set of impassable Coord positions that may change (not constant like walls); can be null
      onlyPassable - a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be null
      start - the start of the path, should correspond to the minimum-x, minimum-y position of the pathfinder
      targets - a vararg or array of Coord that this will try to pathfind toward
      Returns:
      an ArrayList of Coord that will contain the min-x, min-y locations of this creature as it goes toward a target. Copy of path.
    • findFleePathLarge

      public IntVLA findFleePathLarge​(int size, int length, int preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... fearSources)
      Scans the dungeon using CustomDijkstraMap.scanLarge with the listed fearSources and start point, and returns a list of Coord positions (using Manhattan distance) needed to get further from the closest fearSources, meant for running away. The maximum length of the returned list is given by length; if moving the full length of the list would place the mover in a position shared by one of the positions in onlyPassable (which is typically filled with friendly units that can be passed through in multi-tile- movement scenarios), it will recalculate a move so that it does not pass into that cell. The keys in impassable should be the positions of enemies and obstacles that cannot be moved through, and will be ignored if there is a fearSource overlapping one. The preferLongerPaths parameter is meant to be tweaked and adjusted; higher values should make creatures prefer to escape out of doorways instead of hiding in the closest corner, and a value of 1.2 should be typical for many maps. The parameters size, preferLongerPaths, impassable, and the varargs used for fearSources will be cached, and any subsequent calls that use the same values as the last values passed will avoid recalculating unnecessary scans. Calls to findFleePath will cache as if size is 1, and may share a cache with this function. The parameter size refers to the side length of a square unit, such as 2 for a 2x2 unit. The parameter start must refer to the minimum-x, minimum-y cell of that unit if size is > 1, and all positions in the returned path will refer to movement of the minimum-x, minimum-y cell.
      This caches its result in a member field, path, which can be fetched after finding a path and will change with each call to a pathfinding method.
      Parameters:
      size - the side length of the creature trying the find a path
      length - the length of the path to calculate
      preferLongerPaths - Set this to 1.2 if you aren't sure; it will probably need tweaking for different maps.
      impassable - a Set of impassable Coord positions that may change (not constant like walls); can be null
      onlyPassable - a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be null
      start - the start of the path, should correspond to the minimum-x, minimum-y position of the pathfinder
      fearSources - a vararg or array of Coord positions to run away from
      Returns:
      an ArrayList of Coord that will contain the locations of this creature as it goes away from fear sources. Copy of path.
    • findFleePathLarge

      public IntVLA findFleePathLarge​(int size, int length, int scanLimit, int preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... fearSources)
      Scans the dungeon using CustomDijkstraMap.scanLarge with the listed fearSources and start point, and returns a list of Coord positions (using Manhattan distance) needed to get further from the closest fearSources, meant for running away. The maximum length of the returned list is given by length; if moving the full length of the list would place the mover in a position shared by one of the positions in onlyPassable (which is typically filled with friendly units that can be passed through in multi-tile- movement scenarios), it will recalculate a move so that it does not pass into that cell. The keys in impassable should be the positions of enemies and obstacles that cannot be moved through, and will be ignored if there is a fearSource overlapping one. The preferLongerPaths parameter is meant to be tweaked and adjusted; higher values should make creatures prefer to escape out of doorways instead of hiding in the closest corner, and a value of 1.2 should be typical for many maps. The parameters size, preferLongerPaths, impassable, and the varargs used for fearSources will be cached, and any subsequent calls that use the same values as the last values passed will avoid recalculating unnecessary scans. Calls to findFleePath will cache as if size is 1, and may share a cache with this function. The parameter size refers to the side length of a square unit, such as 2 for a 2x2 unit. The parameter start must refer to the minimum-x, minimum-y cell of that unit if size is > 1, and all positions in the returned path will refer to movement of the minimum-x, minimum-y cell.
      This caches its result in a member field, path, which can be fetched after finding a path and will change with each call to a pathfinding method.
      Parameters:
      size - the side length of the creature trying the find a path
      length - the length of the path to calculate
      scanLimit - how many steps away from a goal to calculate; negative scans the whole map
      preferLongerPaths - Set this to 1.2 if you aren't sure; it will probably need tweaking for different maps.
      impassable - a Set of impassable Coord positions that may change (not constant like walls); can be null
      onlyPassable - a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be null
      start - the start of the path, should correspond to the minimum-x, minimum-y position of the pathfinder
      fearSources - a vararg or array of Coord positions to run away from
      Returns:
      an ArrayList of Coord that will contain the locations of this creature as it goes away from fear sources. Copy of path.
    • floodFill

      public IntDoubleOrderedMap floodFill​(int radius, int... starts)
      A simple limited flood-fill that returns a OrderedMap of Coord keys to the Double values in the CustomDijkstraMap, only calculating out to a number of steps determined by limit. This can be useful if you need many flood-fills and don't need a large area for each, or if you want to have an effect spread to a certain number of cells away.
      Parameters:
      radius - the number of steps to take outward from each starting position.
      starts - a vararg group of Points to step outward from; this often will only need to be one Coord.
      Returns:
      A OrderedMap of Coord keys to Double values; the starts are included in this with the value 0.
    • getMappedCount

      public int getMappedCount()