Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pathfinder can get stuck in a state with an active goal when the computed path is not complete #273

Open
IceTank opened this issue Jun 15, 2022 · 1 comment

Comments

@IceTank
Copy link
Collaborator

IceTank commented Jun 15, 2022

This line

if (path.length === 0) {
returns out off the monitorMovements function when the current path length is 0. But if the computed path has no when the AStar result is partial the bot gets stuck until a new goal is set. This causes issues when you set goals with setGoal that are not completed but rely on events to fire when the bot stops. The only event that fires right now is a path update event. But there is no way off knowing if that event was fired because a block changed or because the bot got stuck.

@IceTank
Copy link
Collaborator Author

IceTank commented Jun 15, 2022

Possible fix would be to handle this case within this check that currently does not catch this behavior.

if (path.length === 0) {
lastNodeTime = performance.now()
if (stateGoal && stateMovements) {
if (stateGoal.isEnd(bot.entity.position.floored())) {
if (!dynamicGoal) {
bot.emit('goal_reached', stateGoal)
stateGoal = null
fullStop()
}
} else if (!pathUpdated) {
const results = bot.pathfinder.getPathTo(stateMovements, stateGoal)
bot.emit('path_update', results)
path = results.path
astartTimedout = results.status === 'partial'
pathUpdated = true
}
}
}
But I don't know if changing this might break something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant