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

Promise for condition #95

Open
JernejHabjan opened this issue Sep 23, 2024 · 3 comments
Open

Promise for condition #95

JernejHabjan opened this issue Sep 23, 2024 · 3 comments

Comments

@JernejHabjan
Copy link

Example:

I have an example for "CanMoveToTarget" which returns Promise because in the background I'm using easystarjs to find path, which works async.

Error

Uncaught Error: error stepping tree: expected condition function 'CanMoveToTarget' to return a boolean but returned '[object Promise]'

@nikkorn
Copy link
Owner

nikkorn commented Sep 24, 2024

@JernejHabjan I'd never considered adding support for async condition functions as I'd always thought of condition checks as being instantaneous (preferably inexpensive) operations while the actions themselves would represent long-running operations.

I guess the options are:

  • Add support for condition functions to be promisey.
  • Use an async action (FindPathToTarget or something) to find the path and either have it fail/succeed based on the findPath result OR have it always succeed and you set the findPath result on the agent and then have a following condition to evaluate it.

If the latter is not a valid option for you then I'd be happy to consider the former, I haven't had much in the way of feedback for this library and a fresh perspective is always welcome.

@JernejHabjan
Copy link
Author

Hey. Yes promisey action would work in my case. It's just maybe something to consider to also support that?

@nikkorn
Copy link
Owner

nikkorn commented Sep 25, 2024

I can't think of any downsides to implementing this and it could be useful when we have to rely on inexpensive async operations to get our condition result. I will do this for the next release.

Thanks

JernejHabjan pushed a commit to JernejHabjan/fuzzy-waddle that referenced this issue Mar 1, 2025
## Changes
- IsInRange is now promisey task until this is resolved - nikkorn/mistreevous#95
- attack branch is working with await for cooldown
- attack branch auto-stops if target is dead
- added Log task for easier debugging
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

2 participants