Fix returnBest not being obeyed
This commit is contained in:
parent
34dcc68e15
commit
d9b25c960d
@ -645,7 +645,7 @@ class PathFinder(val world: World<*, *>, val start: Vector2d, val goal: Vector2d
|
|||||||
// release memory associated with structures
|
// release memory associated with structures
|
||||||
openNodes = PriorityQueue()
|
openNodes = PriorityQueue()
|
||||||
closedNodes = HashSet()
|
closedNodes = HashSet()
|
||||||
closest = Node(roundToNode(start))
|
// closest = Node(roundToNode(start))
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -691,7 +691,11 @@ class PathFinder(val world: World<*, *>, val start: Vector2d, val goal: Vector2d
|
|||||||
LOGGER.warn("Path finder tried to consider more than 40000 nodes (goal $goal, closest take $closest, distance ${closest.position.distance(goal)}, onGround ${onGround(closest.position)})")
|
LOGGER.warn("Path finder tried to consider more than 40000 nodes (goal $goal, closest take $closest, distance ${closest.position.distance(goal)}, onGround ${onGround(closest.position)})")
|
||||||
|
|
||||||
if (!canContinue()) {
|
if (!canContinue()) {
|
||||||
result = KOptional(null as List<Edge>?)
|
if (parameters.returnBest) {
|
||||||
|
result = KOptional(closest.reconstructPath())
|
||||||
|
} else {
|
||||||
|
result = KOptional(null as List<Edge>?)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.isPresent)
|
if (result.isPresent)
|
||||||
|
Loading…
Reference in New Issue
Block a user