| Constructor and Description |
|---|
Pathfinder(Decoder<C> decoder) |
| Modifier and Type | Method and Description |
|---|---|
Pathfinder<C> |
addFirstCell(boolean addFirstCell)
Does the first cell (source) should be added to the path ?
|
Pathfinder<C> |
cellWeightFunction(Function<C,Integer> function)
Define the function for compute the cell cost
This function can add penalty on some cells.
|
Pathfinder<C> |
directions(Direction[] directions)
Define the available movements directions
Note : Adding all directions will permit to move in diagonal,
But the pathfinder is not optimal, because the distance is not computed using pythagoras distance
By default, the direction are the restricted directions
|
Pathfinder<C> |
exploredCellLimit(@Positive int limit)
Define the maximum number of cells to explore before fail
A lower limit will fail faster, but do not permit complex path
The limit cannot be higher than walkable cells number
|
Path<C> |
findPath(C source,
C target)
Find the shortest path between source and target cells
|
Pathfinder<C> |
targetDistance(@NonNegative int distance)
Define the minimal target distance to consider the path as reached
A distance of 0 means that the end of the path must be the target cell
A distance of 1 means that the end of the path must be an adjacent cell of the target
By default the value is 0 (the end must be the target)
|
Pathfinder<C> |
walkablePredicate(Predicate<C> predicate)
Define the predicate for check if the cell is walkable
By default the predicate will call
MapCell.walkable() |
public Pathfinder<C> targetDistance(@NonNegative int distance)
distance - The distance in number of cellspublic Pathfinder<C> walkablePredicate(Predicate<C> predicate)
MapCell.walkable()predicate - The predicate to usepublic Pathfinder<C> cellWeightFunction(Function<C,Integer> function)
function - The function to usepublic Pathfinder<C> directions(Direction[] directions)
directions - Allowed directionsDirection.restricted()public Pathfinder<C> exploredCellLimit(@Positive int limit)
limit - The cells number. Must be a positive integerpublic Pathfinder<C> addFirstCell(boolean addFirstCell)
addFirstCell - true to add the first cell (default), or false to disablepublic Path<C> findPath(C source, C target)
source - The source (start) celltarget - The target (end) cellPathException - When cannot found any valid pathCopyright © 2022. All rights reserved.