public abstract class Adjacency
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Adjacency.BasicAdjacency |
static class |
Adjacency.RotationAdjacency |
static class |
Adjacency.ThinWallAdjacency |
Modifier and Type | Field and Description |
---|---|
int |
blockingRule
If you want obstacles present in orthogonal cells to prevent pathfinding along the diagonal between them, this
can be used to make single-cell diagonal walls non-viable to move through, or even to prevent diagonal movement if any
one obstacle is orthogonally adjacent to both the start and target cell of a diagonal move.
|
IntDoubleOrderedMap |
costRules
Used in place of a double[][] of costs in CustomDijkstraMap; allows you to set the costs to enter tiles (via
addCostRule(char, double) or addCostRule(char, double, boolean) if the map has rotations). |
int |
depths
Can be changed if the map changes; you should get the neighbors from neighborMaps() again after changing this.
|
Direction[] |
directions
The array of all possible directions this allows, regardless of cost.
|
int |
height
Can be changed if the map changes; you should get the neighbors from neighborMaps() again after changing this.
|
int[] |
invertAdjacent |
int |
maxAdjacent
The maximum number of states that can be considered adjacent; when rotations are present and have a
cost this is almost always 3 (move forward, turn left, turn right), and in most other cases this is
4 (when using Manhattan distance) or 8 (for other distance metrics).
|
Measurement |
measurement
This affects how distance is measured on diagonal directions vs.
|
int |
rotations
Can be changed if the map changes; you should get the neighbors from neighborMaps() again after changing this.
|
protected boolean |
standardCost |
boolean |
twoStepRule
Only needed for thin-wall maps; this requires two steps in the same direction to both be valid moves
for that direction to be considered, and always moves the pathfinder two steps, typically to cells
with even numbers for both x and y (where odd-number-position cells are used for edges or corners
between cells, and can still be obstacles or possible to pass through, but not stay on).
|
int |
width
Can be changed if the map changes; you should get the neighbors from neighborMaps() again after changing this.
|
Constructor and Description |
---|
Adjacency() |
Modifier and Type | Method and Description |
---|---|
IntDoubleOrderedMap |
addCostRule(char tile,
double cost) |
abstract IntDoubleOrderedMap |
addCostRule(char tile,
double cost,
boolean isRotation) |
abstract int |
composite(int x,
int y,
int r,
int n)
Encodes up to four components used by this Adjacency, putting them into one int.
|
Coord |
extractCoord(int data) |
abstract int |
extractN(int data) |
abstract int |
extractR(int data) |
abstract int |
extractX(int data) |
abstract int |
extractY(int data) |
boolean |
hasStandardCost() |
abstract boolean |
isBlocked(int start,
int direction,
int[][][] neighbors,
double[] map,
double wall) |
int |
move(int start,
int x,
int y) |
int |
move(int start,
int x,
int y,
int r,
int n) |
abstract int[][][] |
neighborMaps() |
abstract void |
portal(int[][][] neighbors,
int inputPortal,
int outputPortal,
boolean twoWay) |
IntDoubleOrderedMap |
putAllVariants(IntDoubleOrderedMap map,
int key,
double value) |
abstract IntDoubleOrderedMap |
putAllVariants(IntDoubleOrderedMap map,
int key,
double value,
int size) |
void |
putAllVariants(IntVLA list,
double[] map,
int key,
double value) |
abstract void |
putAllVariants(IntVLA list,
double[] map,
int key,
double value,
int size) |
void |
resetAllVariants(double[] map,
int[] keys,
double[] values) |
void |
resetAllVariants(double[] map,
int[] keys,
double[] values,
int size) |
abstract void |
resetAllVariants(double[] map,
int[] keys,
int usable,
double[] values,
int size) |
java.lang.String |
show(int data) |
java.lang.String |
showMap(int[] map,
int r) |
abstract boolean |
validate(int data) |
public Direction[] directions
public int maxAdjacent
public boolean twoStepRule
public int blockingRule
public Measurement measurement
public int width
public int height
public int rotations
public int depths
protected boolean standardCost
public IntDoubleOrderedMap costRules
addCostRule(char, double)
or addCostRule(char, double, boolean)
if the map has rotations).
A cost of 1.0 is normal for most implementations; higher costs make a movement harder to perform and take more
time if the game uses that mechanic, while lower costs (which should always be greater than 0.0) make a move
easier to perform. Most games can do perfectly well with just 1.0 and 2.0, if they use this at all, plus possibly
a very high value for impossible moves (say, 9999.0 for something like a submarine trying to enter suburbia).
hasStandardCost()
, but
cannot be set directly).
IntDoubleOrderedMap.defaultReturnValue(double)
; there may be a reason for user code to call this as well.public int[] invertAdjacent
public boolean hasStandardCost()
public abstract int extractX(int data)
public abstract int extractY(int data)
public abstract int extractR(int data)
public abstract int extractN(int data)
public abstract int composite(int x, int y, int r, int n)
extractX(int)
, extractY(int)
, extractR(int)
,
and extractN(int)
, though not all implementations use R and N.x
- the x component to encodey
- the y component to encoder
- the rotation component to encode; not all implementations use rotation and the max value variesn
- the bonus component to encode; this can be used for height or other extra data in some implementationspublic abstract boolean validate(int data)
public Coord extractCoord(int data)
public int move(int start, int x, int y, int r, int n)
public int move(int start, int x, int y)
public abstract int[][][] neighborMaps()
public abstract void portal(int[][][] neighbors, int inputPortal, int outputPortal, boolean twoWay)
public abstract boolean isBlocked(int start, int direction, int[][][] neighbors, double[] map, double wall)
public IntDoubleOrderedMap addCostRule(char tile, double cost)
public abstract IntDoubleOrderedMap addCostRule(char tile, double cost, boolean isRotation)
public IntDoubleOrderedMap putAllVariants(IntDoubleOrderedMap map, int key, double value)
public abstract IntDoubleOrderedMap putAllVariants(IntDoubleOrderedMap map, int key, double value, int size)
public void putAllVariants(IntVLA list, double[] map, int key, double value)
public abstract void putAllVariants(IntVLA list, double[] map, int key, double value, int size)
public void resetAllVariants(double[] map, int[] keys, double[] values)
public void resetAllVariants(double[] map, int[] keys, double[] values, int size)
public abstract void resetAllVariants(double[] map, int[] keys, int usable, double[] values, int size)
public java.lang.String show(int data)
public java.lang.String showMap(int[] map, int r)
Copyright © Eben Howard 2012–2022. All rights reserved.