public class DijkstraMap extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DijkstraMap.Measurement
The type of heuristic to use.
|
Modifier and Type | Field and Description |
---|---|
double[][] |
costMap
This stores the entry cost multipliers for each cell; that is, a value of 1.0 is a normal, unmodified cell, but
a value of 0.5 can be entered easily (two cells of its cost can be entered for the cost of one 1.0 cell), and a
value of 2.0 can only be entered with difficulty (one cell of its cost can be entered for the cost of two 1.0
cells).
|
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.0 .
|
static double |
FLOOR
Floor cells, which include any walkable cell, are marked with a high number equal to 999200.0 .
|
static double |
GOAL
Goals are always marked with 0.
|
LinkedHashMap<Coord,Double> |
goals
Goals that pathfinding will seek out.
|
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.
|
DijkstraMap.Measurement |
measurement
This affects how distance is measured on diagonal directions vs.
|
ArrayList<Coord> |
path
The latest path that was obtained by calling findPath().
|
double[][] |
physicalMap
Stores which parts of the map are accessible and which are not.
|
RNG |
rng
The RNG used to decide which one of multiple equally-short paths to take.
|
double[][] |
safetyMap
A 2D array of modifiers to apply to the perceived safety of an area; modifiers go up when deteriorate() is
called, which makes the cells specified in that method call more dangerous (usually because staying in one place
is perceived as risky).
|
Coord[][] |
targetMap |
static double |
WALL
Walls, which are solid no-entry cells, are marked with a high number equal to 999500.0 .
|
int |
width
Width of the map.
|
Constructor and Description |
---|
DijkstraMap()
Construct a DijkstraMap without a level to actually scan.
|
DijkstraMap(char[][] level)
Constructor meant to take a char[][] returned by DungeonGen.generate(), or any other
char[][] where '#' means a wall and anything else is a walkable tile.
|
DijkstraMap(char[][] level,
char alternateWall)
Constructor meant to take a char[][] returned by DungeonGen.generate(), or any other
char[][] where one char means a wall and anything else is a walkable tile.
|
DijkstraMap(char[][] level,
DijkstraMap.Measurement measurement)
Constructor meant to take a char[][] returned by DungeonGen.generate(), or any other
char[][] where '#' means a wall and anything else is a walkable tile.
|
DijkstraMap(char[][] level,
DijkstraMap.Measurement measurement,
RNG rng)
Constructor meant to take a char[][] returned by DungeonGen.generate(), or any other
char[][] where '#' means a wall and anything else is a walkable tile.
|
DijkstraMap(char[][] level,
RNG rng)
Constructor meant to take a char[][] returned by DungeonGen.generate(), or any other
char[][] where '#' means a wall and anything else is a walkable tile.
|
DijkstraMap(double[][] level)
Used to construct a DijkstraMap from the output of another.
|
DijkstraMap(double[][] level,
DijkstraMap.Measurement measurement)
Used to construct a DijkstraMap from the output of another, specifying a distance calculation.
|
DijkstraMap(RNG random)
Construct a DijkstraMap without a level to actually scan.
|
Modifier and Type | Method and Description |
---|---|
void |
clearGoals()
Used to remove all goals and undo any changes to gradientMap made by having a goal present.
|
double[][] |
deteriorate(Coord... riskyPoints)
Used in conjunction with methods that depend on finding cover, like findCoveredAttackPath(), this method causes
specified risky points to be considered less safe, and will encourage a pathfinder to keep moving toward a goal
instead of just staying in cover forever (or until an enemy moves around the cover and ambushes the pathfinder).
|
double[][] |
deteriorate(List<Coord> riskyPoints)
Used in conjunction with methods that depend on finding cover, like findCoveredAttackPath(), this method causes
specified risky points to be considered less safe, and will encourage a pathfinder to keep moving toward a goal
instead of just staying in cover forever (or until an enemy moves around the cover and ambushes the pathfinder).
|
ArrayList<Coord> |
findAttackPath(int moveLength,
int preferredRange,
FOVCache cache,
Set<Coord> impassable,
Set<Coord> onlyPassable,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list
of Coord positions (using the current measurement) needed to get closer to a goal, until preferredRange is
reached, or further from a goal if the preferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findAttackPath(int moveLength,
int minPreferredRange,
int maxPreferredRange,
FOVCache cache,
Set<Coord> impassable,
Set<Coord> onlyPassable,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list
of Coord positions (using the current measurement) needed to get closer to a goal, until a cell is reached with
a distance from a goal that is at least equal to minPreferredRange and no more than maxPreferredRange,
which may go further from a goal if the minPreferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findAttackPath(int moveLength,
int minPreferredRange,
int maxPreferredRange,
LOS los,
Set<Coord> impassable,
Set<Coord> onlyPassable,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list
of Coord positions (using the current measurement) needed to get closer to a goal, until a cell is reached with
a distance from a goal that is at least equal to minPreferredRange and no more than maxPreferredRange,
which may go further from a goal if the minPreferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findAttackPath(int moveLength,
int preferredRange,
LOS los,
Set<Coord> impassable,
Set<Coord> onlyPassable,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list
of Coord positions (using the current measurement) needed to get closer to a goal, until preferredRange is
reached, or further from a goal if the preferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findAttackPathLarge(int size,
int moveLength,
int minPreferredRange,
int maxPreferredRange,
LOS los,
Set<Coord> impassable,
Set<Coord> onlyPassable,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list
of Coord positions (using the current measurement) needed to get closer to a goal, until a cell is reached with
a distance from a goal that is at least equal to minPreferredRange and no more than maxPreferredRange,
which may go further from a goal if the minPreferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findAttackPathLarge(int size,
int moveLength,
int preferredRange,
LOS los,
Set<Coord> impassable,
Set<Coord> onlyPassable,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list
of Coord positions (using the current measurement) needed to get closer to a goal, until preferredRange is
reached, or further from a goal if the preferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findCoveredAttackPath(int moveLength,
int preferredRange,
double coverPreference,
FOV fov,
boolean seekDistantGoals,
Set<Coord> impassable,
Set<Coord> onlyPassable,
List<Threat> threats,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list of Coord
positions (using the current measurement) needed to get closer to a goal while staying in areas that none of the
given threats are able to see (which should prevent them from attacking), until a cell is reached with
a distance from a goal that is at equal to preferredRange,
which may go further from a goal if the preferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findCoveredAttackPath(int moveLength,
int preferredRange,
double coverPreference,
FOVCache fov,
boolean seekDistantGoals,
Set<Coord> impassable,
Set<Coord> onlyPassable,
List<Threat> threats,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list of Coord
positions (using the current measurement) needed to get closer to a goal while staying in areas that none of the
given threats are able to see (which should prevent them from attacking), until a cell is reached with
a distance from a goal that is at equal to preferredRange,
which may go further from a goal if the preferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findCoveredAttackPath(int moveLength,
int minPreferredRange,
int maxPreferredRange,
double coverPreference,
FOV fov,
boolean seekDistantGoals,
Set<Coord> impassable,
Set<Coord> onlyPassable,
List<Threat> threats,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list of Coord
positions (using the current measurement) needed to get closer to a goal while staying in areas that none of the
given threats are able to see (which should prevent them from attacking), until a cell is reached with
a distance from a goal that is at least equal to minPreferredRange and no more than maxPreferredRange,
which may go further from a goal if the minPreferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findCoveredAttackPath(int moveLength,
int minPreferredRange,
int maxPreferredRange,
double coverPreference,
FOVCache fov,
boolean seekDistantGoals,
Set<Coord> impassable,
Set<Coord> onlyPassable,
List<Threat> threats,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list of Coord
positions (using the current measurement) needed to get closer to a goal while staying in areas that none of the
given threats are able to see (which should prevent them from attacking), until a cell is reached with
a distance from a goal that is at least equal to minPreferredRange and no more than maxPreferredRange,
which may go further from a goal if the minPreferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findCoveredAttackPath(int moveLength,
int minPreferredRange,
int maxPreferredRange,
double coverPreference,
Set<Coord> impassable,
Set<Coord> onlyPassable,
List<Threat> threats,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list of Coord
positions (using the current measurement) needed to get closer to a goal while staying in areas that none of the
given threats are able to see (which should prevent them from attacking), until a cell is reached with
a distance from a goal that is at least equal to minPreferredRange and no more than maxPreferredRange,
which may go further from a goal if the minPreferredRange has not been met at the current distance.
|
ArrayList<Coord> |
findFleePath(int length,
double preferLongerPaths,
Set<Coord> impassable,
Set<Coord> onlyPassable,
Coord start,
Coord... fearSources)
Scans the dungeon using DijkstraMap.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.
|
ArrayList<Coord> |
findFleePathLarge(int size,
int length,
double preferLongerPaths,
Set<Coord> impassable,
Set<Coord> onlyPassable,
Coord start,
Coord... fearSources)
Scans the dungeon using DijkstraMap.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.
|
static DijkstraMap.Measurement |
findMeasurement(Radius radius)
Gets the appropriate DijkstraMap.Measurement to pass to a constructor if you already have a Radius.
|
Coord |
findNearest(Coord start,
Coord... targets)
Recalculate the Dijkstra map until it reaches a Coord in targets, then returns the first target found.
|
Coord |
findNearest(Coord start,
Set<Coord> targets)
Recalculate the Dijkstra map until it reaches a Coord in targets, then returns the first target found.
|
ArrayList<Coord> |
findNearestMultiple(Coord start,
int limit,
Set<Coord> targets)
Recalculate the Dijkstra map until it reaches a Coord in targets, then returns the first several targets found,
up to limit or less if the map is fully searched without finding enough.
|
ArrayList<Coord> |
findPath(int length,
Set<Coord> impassable,
Set<Coord> onlyPassable,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.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.
|
ArrayList<Coord> |
findPathLarge(int size,
int length,
Set<Coord> impassable,
Set<Coord> onlyPassable,
Coord start,
Coord... targets)
Scans the dungeon using DijkstraMap.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.
|
ArrayList<Coord> |
findPathPreScanned(Coord target)
Intended primarily for internal use.
|
static Radius |
findRadius(DijkstraMap.Measurement measurement)
Gets the appropriate Radius corresponding to a DijkstraMap.Measurement.
|
ArrayList<Coord> |
findShortcutPath(Coord start,
Coord... targets)
If you have a target or group of targets you want to pathfind to without scanning the full map, this can be good.
|
ArrayList<Coord> |
findTechniquePath(int moveLength,
Technique tech,
char[][] dungeon,
FOVCache cache,
Set<Coord> impassable,
Set<Coord> allies,
Coord start,
Set<Coord> targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list
of Coord positions (using the current measurement) needed to get closer to a goal, where goals are
considered valid if they are at a valid range for the given Technique to hit at least one target
and ideal if that Technique can affect as many targets as possible from a cell that can be moved
to with at most movelength steps.
|
ArrayList<Coord> |
findTechniquePath(int moveLength,
Technique tech,
char[][] dungeon,
LOS los,
Set<Coord> impassable,
Set<Coord> allies,
Coord start,
Set<Coord> targets)
Scans the dungeon using DijkstraMap.scan with the listed goals and start point, and returns a list
of Coord positions (using the current measurement) needed to get closer to a goal, where goals are
considered valid if they are at a valid range for the given Technique to hit at least one target
and ideal if that Technique can affect as many targets as possible from a cell that can be moved
to with at most movelength steps.
|
LinkedHashMap<Coord,Double> |
floodFill(int radius,
Coord... starts)
A simple limited flood-fill that returns a LinkedHashMap of Coord keys to the Double values in the DijkstraMap, only
calculating out to a number of steps determined by limit.
|
int |
getMappedCount() |
DijkstraMap |
initialize(char[][] level)
Used to initialize or re-initialize a DijkstraMap 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() ).
|
DijkstraMap |
initialize(char[][] level,
char alternateWall)
Used to initialize or re-initialize a DijkstraMap 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() ).
|
DijkstraMap |
initialize(double[][] level)
Used to initialize or re-initialize a DijkstraMap 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() ).
|
DijkstraMap |
initializeCost(char[][] level)
Used to initialize the entry cost modifiers for games that require variable costs to enter squares.
|
DijkstraMap |
initializeCost(char[][] level,
char alternateWall)
Used to initialize the entry cost modifiers for games that require variable costs to enter squares.
|
DijkstraMap |
initializeCost(double[][] costs)
Used to initialize the entry cost modifiers for games that require variable costs to enter squares.
|
double[][] |
partialScan(int limit,
Set<Coord> impassable)
Recalculate the Dijkstra map up to a limit and return it.
|
double[][] |
relax(Coord... saferPoints)
Used in conjunction with methods that depend on finding cover, like findCoveredAttackPath(), this method causes
specified safer points to be considered more safe, and will make a pathfinder more likely to enter those places
if they were considered dangerous earlier (due to calling deteriorate()).
|
double[][] |
relax(List<Coord> saferPoints)
Used in conjunction with methods that depend on finding cover, like findCoveredAttackPath(), this method causes
specified safer points to be considered more safe, and will make a pathfinder more likely to enter those places
if they were considered dangerous earlier (due to calling deteriorate()).
|
void |
reset()
Resets this DijkstraMap to a state with no goals, no discovered path, and no changes made to gradientMap
relative to physicalMap.
|
void |
resetCell(Coord pt)
Reverts a cell to the value stored in the original state of the level as known by physicalMap.
|
void |
resetCell(int x,
int y)
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.
|
void |
resetSafetyMap()
Resets the targetMap (which is only assigned in the first place if you use findTechniquePath() ).
|
void |
resetTargetMap()
Resets the targetMap (which is only assigned in the first place if you use findTechniquePath() ).
|
double[][] |
scan(Set<Coord> impassable)
Recalculate the Dijkstra map and return it.
|
double[][] |
scan(Set<Coord> impassable,
int size)
Recalculate the Dijkstra map for a creature that is potentially larger than 1x1 cell and return it.
|
void |
setCost(Coord pt,
double cost)
Marks a cell's cost for pathfinding as cost, unless the cell is a wall or unreachable area (then it always sets
the cost to the value of the WALL field).
|
void |
setCost(int x,
int y,
double cost)
Marks a cell's cost for pathfinding as cost, unless the cell is a wall or unreachable area (then it always sets
the cost to the value of the WALL field).
|
protected void |
setFresh(Coord pt,
double counter) |
protected void |
setFresh(int x,
int y,
double counter) |
void |
setGoal(Coord pt)
Marks a cell as a goal for pathfinding, unless the cell is a wall or unreachable area (then it does nothing).
|
void |
setGoal(int x,
int y)
Marks a cell as a goal for pathfinding, unless the cell is a wall or unreachable area (then it does nothing).
|
void |
setOccupied(int x,
int y)
Marks a specific cell in gradientMap as completely impossible to enter.
|
public DijkstraMap.Measurement measurement
public double[][] physicalMap
public double[][] gradientMap
public double[][] safetyMap
public double[][] costMap
public int height
public int width
public ArrayList<Coord> path
public static final double GOAL
public static final double FLOOR
public static final double WALL
public static final double DARK
public LinkedHashMap<Coord,Double> goals
public DijkstraMap()
public DijkstraMap(RNG random)
public DijkstraMap(double[][] level)
level
- public DijkstraMap(double[][] level, DijkstraMap.Measurement measurement)
level
- measurement
- public DijkstraMap(char[][] level)
level
- public DijkstraMap(char[][] level, RNG rng)
level
- rng
- The RNG to use for certain decisions; only affects find* methods like findPath, not scan.public DijkstraMap(char[][] level, char alternateWall)
level
- public DijkstraMap(char[][] level, DijkstraMap.Measurement measurement)
level
- measurement
- public DijkstraMap(char[][] level, DijkstraMap.Measurement measurement, RNG rng)
level
- rng
- The RNG to use for certain decisions; only affects find* methods like findPath, not scan.public int getMappedCount()
public DijkstraMap initialize(double[][] level)
level
- public DijkstraMap initialize(char[][] level)
level
- public DijkstraMap initialize(char[][] level, char alternateWall)
level
- alternateWall
- public DijkstraMap initializeCost(char[][] level)
level
- a 2D char array that uses '#' for wallspublic DijkstraMap initializeCost(char[][] level, char alternateWall)
level
- a 2D char array that uses alternateChar for walls.alternateWall
- a char to use to represent walls.public DijkstraMap initializeCost(double[][] costs)
costs
- a 2D double array that already has the desired cost valuespublic static DijkstraMap.Measurement findMeasurement(Radius radius)
radius
- the Radius to find the corresponding Measurement forpublic static Radius findRadius(DijkstraMap.Measurement measurement)
measurement
- the Measurement to find the corresponding Radius forpublic void resetMap()
public void resetTargetMap()
public void resetSafetyMap()
public void reset()
public void setGoal(int x, int y)
x
- y
- public void setGoal(Coord pt)
pt
- public void setCost(Coord pt, double cost)
pt
- cost
- public void setCost(int x, int y, double cost)
x
- y
- cost
- public void setOccupied(int x, int y)
x
- y
- public void resetCell(int x, int y)
x
- y
- public void resetCell(Coord pt)
pt
- public void clearGoals()
protected void setFresh(int x, int y, double counter)
public double[][] deteriorate(List<Coord> riskyPoints)
riskyPoints
- a List of Coord that should be considered more risky to stay at with each call.public double[][] deteriorate(Coord... riskyPoints)
riskyPoints
- a vararg or array of Coord that should be considered more risky to stay at with each call.public double[][] relax(List<Coord> saferPoints)
saferPoints
- a List of Coord that should be considered less risky to stay at with each call.public double[][] relax(Coord... saferPoints)
saferPoints
- a vararg or array of Coord that should be considered less risky to stay at with each call.public double[][] scan(Set<Coord> impassable)
impassable
- A Set of Position 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.public double[][] partialScan(int limit, Set<Coord> impassable)
limit
- The maximum number of steps to scan outward from a goal.impassable
- A Set of Position 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.public Coord findNearest(Coord start, Set<Coord> targets)
start
- the cell to use as the origin for finding the nearest targettargets
- the Coords that this is trying to find; it will stop once it finds onepublic Coord findNearest(Coord start, Coord... targets)
start
- the cell to use as the origin for finding the nearest targettargets
- the Coords that this is trying to find; it will stop once it finds onepublic ArrayList<Coord> findShortcutPath(Coord start, Coord... targets)
start
- your starting locationtargets
- an array or vararg of Coords to pathfind to the nearest ofpublic ArrayList<Coord> findNearestMultiple(Coord start, int limit, Set<Coord> targets)
start
- the cell to use as the origin for finding the nearest targetslimit
- the maximum number of targets to find before returningtargets
- the Coords that this is trying to find; it will stop once it finds enough (based on limit)public double[][] scan(Set<Coord> impassable, int size)
impassable
- A Set of Position 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.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.public ArrayList<Coord> findPath(int length, Set<Coord> impassable, Set<Coord> onlyPassable, Coord start, Coord... targets)
length
- the length of the path to calculateimpassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullstart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findAttackPath(int moveLength, int preferredRange, LOS los, Set<Coord> impassable, Set<Coord> onlyPassable, Coord start, Coord... targets)
moveLength
- the length of the path to calculatepreferredRange
- the distance this unit will try to keep from a targetlos
- a squidgrid.LOS object if the preferredRange should try to stay in line of sight, or null if LoS
should be disregarded.impassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullstart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findAttackPath(int moveLength, int minPreferredRange, int maxPreferredRange, LOS los, Set<Coord> impassable, Set<Coord> onlyPassable, Coord start, Coord... targets)
moveLength
- the length of the path to calculateminPreferredRange
- the (inclusive) lower bound of the distance this unit will try to keep from a targetmaxPreferredRange
- the (inclusive) upper bound of the distance this unit will try to keep from a targetlos
- a squidgrid.LOS object if the preferredRange should try to stay in line of sight, or null if LoS
should be disregarded.impassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullstart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findTechniquePath(int moveLength, Technique tech, char[][] dungeon, LOS los, Set<Coord> impassable, Set<Coord> allies, Coord start, Set<Coord> targets)
moveLength
- the maximum distance to try to pathfind out to; if a spot to use a Technique can be found
while moving no more than this distance, then the targetMap field in this object will have a
target Coord that is ideal for the given Technique at the x, y indices corresponding to the
last Coord in the returned path.tech
- a Technique that we will try to find an ideal place to use, and/or a path toward that place.dungeon
- a char 2D array with '#' for walls.los
- a squidgrid.LOS object if the preferred range should try to stay in line of sight, or null if LoS
should be disregarded.impassable
- locations of enemies or mobile hazards/obstacles that aren't in the map as wallsallies
- called onlyPassable in other methods, here it also represents allies for Technique thingsstart
- the Coord the pathfinder starts at.targets
- a Set of Coord, not an array of Coord or variable argument list as in other methods.public ArrayList<Coord> findAttackPath(int moveLength, int preferredRange, FOVCache cache, Set<Coord> impassable, Set<Coord> onlyPassable, Coord start, Coord... targets)
moveLength
- the length of the path to calculatepreferredRange
- the distance this unit will try to keep from a targetcache
- a FOVCache that has completed its calculations, and will be used for LOS work, may be nullimpassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullstart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findAttackPath(int moveLength, int minPreferredRange, int maxPreferredRange, FOVCache cache, Set<Coord> impassable, Set<Coord> onlyPassable, Coord start, Coord... targets)
moveLength
- the length of the path to calculateminPreferredRange
- the (inclusive) lower bound of the distance this unit will try to keep from a targetmaxPreferredRange
- the (inclusive) upper bound of the distance this unit will try to keep from a targetcache
- a FOVCache that has completed its calculations, and will be used for LOS work, may be nullimpassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullstart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findCoveredAttackPath(int moveLength, int minPreferredRange, int maxPreferredRange, double coverPreference, Set<Coord> impassable, Set<Coord> onlyPassable, List<Threat> threats, Coord start, Coord... targets)
moveLength
- the length of the path to calculateminPreferredRange
- the (inclusive) lower bound of the distance this unit will try to keep from a targetmaxPreferredRange
- the (inclusive) upper bound of the distance this unit will try to keep from a targetcoverPreference
- positive, typically around 1.0, higher numbers make the pathfinder stay behind cover
more, lower numbers make the pathfinder move more aggressively toward targetsimpassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullthreats
- a List of Threat objects that store a position, min and max threatening distancestart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findCoveredAttackPath(int moveLength, int preferredRange, double coverPreference, FOV fov, boolean seekDistantGoals, Set<Coord> impassable, Set<Coord> onlyPassable, List<Threat> threats, Coord start, Coord... targets)
moveLength
- the length of the path to calculatepreferredRange
- the distance this unit will try to keep from a targetfov
- a FOV that will be used for LOS work, must not be nullseekDistantGoals
- true if this should pathfind to goals that it cannot see, false if FOV restricts pathfindingimpassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullthreats
- a List of Threat objects that store a position, min and max threatening distancestart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findCoveredAttackPath(int moveLength, int minPreferredRange, int maxPreferredRange, double coverPreference, FOV fov, boolean seekDistantGoals, Set<Coord> impassable, Set<Coord> onlyPassable, List<Threat> threats, Coord start, Coord... targets)
moveLength
- the length of the path to calculateminPreferredRange
- the (inclusive) lower bound of the distance this unit will try to keep from a targetmaxPreferredRange
- the (inclusive) upper bound of the distance this unit will try to keep from a targetcoverPreference
- positive, typically around 1.0, higher numbers make the pathfinder stay behind cover
more, lower numbers make the pathfinder move more aggressively toward targetsfov
- a FOV that will be used for LOS work, MUST NOT be nullseekDistantGoals
- true if this should pathfind to goals that it cannot see, false if FOV restricts pathfindingimpassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullthreats
- a List of Threat objects that store a position, min and max threatening distancestart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findCoveredAttackPath(int moveLength, int preferredRange, double coverPreference, FOVCache fov, boolean seekDistantGoals, Set<Coord> impassable, Set<Coord> onlyPassable, List<Threat> threats, Coord start, Coord... targets)
moveLength
- the length of the path to calculatepreferredRange
- the distance this unit will try to keep from a targetfov
- a FOVCache that has completed its calculations, and will be used for LOS work, may be nullseekDistantGoals
- true if this should pathfind to goals that it cannot see, false if FOV restricts pathfindingimpassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullthreats
- a List of Threat objects that store a position, min and max threatening distancestart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findCoveredAttackPath(int moveLength, int minPreferredRange, int maxPreferredRange, double coverPreference, FOVCache fov, boolean seekDistantGoals, Set<Coord> impassable, Set<Coord> onlyPassable, List<Threat> threats, Coord start, Coord... targets)
moveLength
- the length of the path to calculateminPreferredRange
- the (inclusive) lower bound of the distance this unit will try to keep from a targetmaxPreferredRange
- the (inclusive) upper bound of the distance this unit will try to keep from a targetcoverPreference
- positive, typically around 1.0, higher numbers make the pathfinder stay behind cover
more, lower numbers make the pathfinder move more aggressively toward targetsfov
- a FOVCache that has completed its calculations, and will be used for LOS workseekDistantGoals
- true if this should pathfind to goals that it cannot see, false if FOV restricts pathfindingimpassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullthreats
- a List of Threat objects that store a position, min and max threatening distancestart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findTechniquePath(int moveLength, Technique tech, char[][] dungeon, FOVCache cache, Set<Coord> impassable, Set<Coord> allies, Coord start, Set<Coord> targets)
moveLength
- the maximum distance to try to pathfind out to; if a spot to use a Technique can be found
while moving no more than this distance, then the targetMap field in this object will have a
target Coord that is ideal for the given Technique at the x, y indices corresponding to the
last Coord in the returned path.tech
- a Technique that we will try to find an ideal place to use, and/or a path toward that place.dungeon
- a char 2D array with '#' for walls.cache
- a FOVCache that has completed its calculations, and will be used for LOS and Technique work, may be nullimpassable
- locations of enemies or mobile hazards/obstacles that aren't in the map as wallsallies
- called onlyPassable in other methods, here it also represents allies for Technique thingsstart
- the Coord the pathfinder starts at.targets
- a Set of Coord, not an array of Coord or variable argument list as in other methods.public ArrayList<Coord> findFleePath(int length, double preferLongerPaths, Set<Coord> impassable, Set<Coord> onlyPassable, Coord start, Coord... fearSources)
length
- the length of the path to calculatepreferLongerPaths
- 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 nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullstart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfinderfearSources
- a vararg or array of Coord positions to run away frompublic ArrayList<Coord> findPathLarge(int size, int length, Set<Coord> impassable, Set<Coord> onlyPassable, Coord start, Coord... targets)
size
- the side length of the creature trying to find a pathlength
- the length of the path to calculateimpassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullstart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findAttackPathLarge(int size, int moveLength, int preferredRange, LOS los, Set<Coord> impassable, Set<Coord> onlyPassable, Coord start, Coord... targets)
size
- the side length of the creature trying to find a pathmoveLength
- the length of the path to calculatepreferredRange
- the distance this unit will try to keep from a targetlos
- a squidgrid.LOS object if the preferredRange should try to stay in line of sight, or null if LoS
should be disregarded.impassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullstart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findAttackPathLarge(int size, int moveLength, int minPreferredRange, int maxPreferredRange, LOS los, Set<Coord> impassable, Set<Coord> onlyPassable, Coord start, Coord... targets)
size
- the side length of the creature trying to find a pathmoveLength
- the length of the path to calculateminPreferredRange
- the (inclusive) lower bound of the distance this unit will try to keep from a targetmaxPreferredRange
- the (inclusive) upper bound of the distance this unit will try to keep from a targetlos
- a squidgrid.LOS object if the preferredRange should try to stay in line of sight, or null if LoS
should be disregarded.impassable
- a Set of impassable Coord positions that may change (not constant like walls); can be nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullstart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfindertargets
- a vararg or array of Coord that this will try to pathfind towardpublic ArrayList<Coord> findFleePathLarge(int size, int length, double preferLongerPaths, Set<Coord> impassable, Set<Coord> onlyPassable, Coord start, Coord... fearSources)
size
- the side length of the creature trying the find a pathlength
- the length of the path to calculatepreferLongerPaths
- 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 nullonlyPassable
- a Set of Coord positions that this pathfinder cannot end a path occupying (typically allies); can be nullstart
- the start of the path, should correspond to the minimum-x, minimum-y position of the pathfinderfearSources
- a vararg or array of Coord positions to run away frompublic ArrayList<Coord> findPathPreScanned(Coord target)
target
- the target cellpublic LinkedHashMap<Coord,Double> floodFill(int radius, Coord... starts)
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.Copyright © 2012–2016. All rights reserved.