public class CustomDijkstraMap
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and 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 and 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,
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,
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,
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,
Adjacency adjacency)
Used to construct a CustomDijkstraMap from the output of another, specifying a distance calculation.
|
CustomDijkstraMap(double[] level,
int width,
int height)
Used to construct a CustomDijkstraMap from the output of another.
|
CustomDijkstraMap(IRNG random)
Construct a CustomDijkstraMap 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.
|
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.
|
public Adjacency adjacency
Adjacency.BasicAdjacency
should cause this class to mimic DijkstraMap
, but using
Adjacency.RotationAdjacency
will be very different.public double[] physicalMap
public double[] gradientMap
public int[] costMap
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.public int[][][] neighbors
Adjacency.portal(int[][][], int, int, boolean)
if you want to create portals between non-adjacent cells.public int height
public int width
public IntVLA path
public static final double GOAL
public static final double FLOOR
public static final double WALL
public static final double DARK
protected IntVLA goals
protected IntVLA fresh
public IRNG rng
public CustomDijkstraMap()
public CustomDijkstraMap(IRNG random)
public CustomDijkstraMap(double[] level, int width, int height)
level
- public CustomDijkstraMap(double[] level, Adjacency adjacency)
level
- adjacency
- public CustomDijkstraMap(char[][] level)
level
- public CustomDijkstraMap(char[][] level, IRNG rng)
level
- rng
- The RNG to use for certain decisions; only affects find* methods like findPath, not scan.public CustomDijkstraMap(char[][] level, char alternateWall)
level
- public CustomDijkstraMap(char[][] level, Adjacency adjacency)
level
- adjacency
- public CustomDijkstraMap(char[][] level, Adjacency adjacency, IRNG rng)
level
- rng
- The IRNG, such as an RNG, to use for certain decisions; only affects find* methods like findPath, not scan.public CustomDijkstraMap initialize(double[] level)
level
- public CustomDijkstraMap initialize(char[][] level)
level
- public CustomDijkstraMap initialize(char[][] level, char alternateWall)
level
- alternateWall
- public CustomDijkstraMap initializeCost(char[][] level)
level
- a 2D char array that uses '#' for wallspublic CustomDijkstraMap initializeCost(int[] tiles)
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.tiles
- an int array that already has tile types that adjacency
can find values forpublic static Measurement findMeasurement(Radius radius)
radius
- the Radius to find the corresponding Measurement forpublic static Radius findRadius(Measurement measurement)
measurement
- the Measurement to find the corresponding Radius forpublic void resetMap()
public void reset()
public void setGoal(int pt)
pt
- public void setCost(int pt, int tile)
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).pt
- the encoded position/rotation/height to set the cost fortile
- typically a char such as '.' for floors, but if this uses rotation, turns on that tile are differentpublic void setOccupied(int pt)
pt
- public void resetCell(int pt)
pt
- public void clearGoals()
protected void setFresh(int pt, double counter)
public boolean isBlocked(int start, int direction)
public double[] scan(int usable, int[] impassable)
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).public double[] scan(IntVLA impassable)
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).public double[] scanToStart(int start, int usable, int[] impassable)
start
- the encoded index of the start of the pathfinder; when this has a path from goal to start, it endsusable
- 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).public double[] scanToStart(int start, IntVLA impassable)
start
- the encoded index of the start of the pathfinder; when this has a path from goal to start, it endsimpassable
- 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).protected void scanInternal(int start, int[] impassable, int usable)
public double[] partialScan(int limit, int usable, int[] impassable)
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.public double[] partialScan(int limit, IntVLA impassable)
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.public double[] partialScanToStart(int limit, int start, int usable, int[] impassable)
start
- the encoded index of the start of the pathfinder; when this has a path from goal to start, it endslimit
- 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).public double[] partialScanToStart(int limit, int start, IntVLA impassable)
start
- the encoded index of the start of the pathfinder; when this has a path from goal to start, it endslimit
- 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).protected void partialScanInternal(int start, int limit, int[] impassable, int usable)
public double[] scanLarge(int size, int usable, int[] impassable)
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.public double[] scanLarge(int size, IntVLA impassable)
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.public double[] scanToStartLarge(int size, int start, int usable, int[] impassable)
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 endsusable
- 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.public double[] scanToStartLarge(int size, int start, IntVLA impassable)
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 endsimpassable
- 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.protected void scanLargeInternal(int start, int size, int[] impassable, int usable)
public double[] partialScanLarge(int size, int limit, int usable, int[] impassable)
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.public double[] partialScanLarge(int size, int limit, IntVLA impassable)
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.public double[] partialScanToStartLarge(int size, int limit, int start, int usable, int[] impassable)
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 endsusable
- 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.public double[] partialScanToStartLarge(int size, int limit, int start, IntVLA impassable)
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 endsimpassable
- 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.protected void partialScanLargeInternal(int start, int size, int limit, int[] impassable, int usable)
public IntVLA findPath(int length, IntVLA impassable, IntVLA onlyPassable, int start, int... 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 IntVLA findPath(int length, int scanLimit, IntVLA impassable, IntVLA onlyPassable, int start, int... 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 IntVLA findFleePath(int length, double preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... 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 IntVLA findFleePath(int length, int scanLimit, double preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... fearSources)
length
- the length of the path to calculatescanLimit
- how many steps away from a fear source to calculate; negative scans the whole mappreferLongerPaths
- 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 IntVLA findPathLarge(int size, int length, IntVLA impassable, IntVLA onlyPassable, int start, int... 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 IntVLA findPathLarge(int size, int length, int scanLimit, IntVLA impassable, IntVLA onlyPassable, int start, int... targets)
size
- the side length of the creature trying to find a pathlength
- the length of the path to calculatescanLimit
- how many steps away from a goal to calculate; negative scans the whole mapimpassable
- 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 IntVLA findFleePathLarge(int size, int length, int preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... 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 IntVLA findFleePathLarge(int size, int length, int scanLimit, int preferLongerPaths, IntVLA impassable, IntVLA onlyPassable, int start, int... fearSources)
size
- the side length of the creature trying the find a pathlength
- the length of the path to calculatescanLimit
- how many steps away from a goal to calculate; negative scans the whole mappreferLongerPaths
- 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 IntDoubleOrderedMap floodFill(int radius, int... 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.public int getMappedCount()
Copyright © Eben Howard 2012–2022. All rights reserved.