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

Allow thinker to restart a given action #66

Open
cBournhonesque opened this issue Jan 6, 2023 · 0 comments
Open

Allow thinker to restart a given action #66

cBournhonesque opened this issue Jan 6, 2023 · 0 comments

Comments

@cBournhonesque
Copy link
Contributor

cBournhonesque commented Jan 6, 2023

I have another issue:

  • i have a pathfinding agent that is trying to find food
  • my scorer computes a score for 'find-food', and puts in an intermediate component the position of the food to eat
  • then i have a sequence action consisting of 'FindFoodPath' (compute the path) and 'WalkOnPath' (just execute the path)

But what I would like is this:

  • the systems keep running, and if the FindFoodScorer gets a higher scorer than the original FindFoodScorer that started the sequence, then I cancel the current sequence and I start a new one.
  • I thought this is already what would happen (the scorer cancels the current action and executes a new one if the scorer becomes higher). But the problem is that this time the action chosen is the same one, just for a different parameter (different food to eat), so the Thinker doesn't cancel the existing FindFoodPath + WalkOnPath sequence.
  • I can probably find workarounds, but they are a bit clunky. It's just something to think about: how to allow the thinker to cancel the current action to re-start an action of the same type
    let get_food = Steps::build()
        .label("GetFood")
        .step(FindFood)
        .step(GoTo);

    Thinker::build()
        .label("DefaultThinker")
        .picker(Highest)
        .when(HungryScorer, get_food)
  • HungryScorer: finds the closest food and assigns a score based on how close it is.
  • GetFood: find a path to the food chosen by HungryScorer and executes on the path
    What i would like is:
  • if at some point HungryScorer finds a better food (closer food position, = higher score), then I cancel my current get_food action and start a new one
    i.e. some kind of mode where the Action stores the original Score value that triggered it, and if the Scorer gets higher score, we restart the action (even if it's the same action-type)

Potential solutions

  • In Here, allow cancelling the current action if the new-score for the same action is higher than the original score (instead of only spawning a new action if its a different action-type)

  • For a given action A, add a way for A to constantly have access to the score that leads to action A + the original score that led to action A being picked. (maybe just a link the corresponding scorer entity?) -> might not be enough in the case of Steps, because a user can only access individual actions that compose steps, not steps itself, unless Steps is refactored a bit)

  • basically a HighestUnchanging picker, that remembers which Choice it picked, and then picks "None" if the score for that item has changed. Make sure that when None is picked, the current action is Canceled.

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