-
Notifications
You must be signed in to change notification settings - Fork 0
/
PathingStrategy.java
32 lines (31 loc) · 984 Bytes
/
PathingStrategy.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.List;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
public interface PathingStrategy
{
/*
* Returns a prefix of a path from the start point to a point
within reach
* of the end point. This path is only valid ("clear") when
returned, but
* may be invalidated by movement of other entities.
*
* The prefix includes neither the start point nor the end
point.
*/
List<Point> computePath(Point start, Point end,
Predicate<Point> canPassThrough,
BiPredicate<Point, Point> withinReach,
Function<Point, Stream<Point>> potentialNeighbors);
static final Function<Point, Stream<Point>> CARDINAL_NEIGHBORS
=
point ->
Stream.<Point>builder()
.add(new Point(point.x, point.y - 1))
.add(new Point(point.x, point.y + 1))
.add(new Point(point.x - 1, point.y))
.add(new Point(point.x + 1, point.y))
.build();
}