-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
FirstToScore
cancels ongoing action when different action passes threshold
#73
Comments
This is working as intended. FirstToScore means "every cycle, check from top to bottom, and pick the first item that scores above the threshold". If that item changes between cycles, the cancellation will happen. The picker is about which action is picked on every individual test, not between action runs. |
Got it, thanks for clarifying that! I wonder how it would be possible to implement it so that it would behave as I'd like? Should I try to implement a custom Picker that would achieve that? Or is there a better/simpler way? |
@ZilvinasAbr unless I'm missing something, you shouldn't need to implement a custom picker or anything: |
Ok, so I tried to do this: ActionState::Executing | ActionState::Cancelled => { for all the actions (eat food,drink water and go to food/water). Essentially, finishing the current action even if thinker tries to cancel it. But now the issue is that I don't know how to enforce that a multi step action would be completed before moving to do another multi step action.
|
You should take |
I think I'm having a similar issue as @ZilvinasAbr and apologies if I don't understand the internals properly. There is a set of Action steps that shouldn't be cancelled, and FirstToScore is cancelling it. I want the whole Maybe another option is to somehow ignore the CancelledState and be able to complete the Action and the steps afterwards. e.g. My use case is a little ant colony: AntType::Scout => Thinker::build()
.label("ScoutThinker")
.picker(FirstToScore { threshold: 0.5 })
.when(HungryScorer, eat_food())
.otherwise(discover_food_and_offer_to_the_queen_steps()), pub fn eat_food() -> StepsBuilder {
Steps::build()
.label("Eat")
.step(SetPathToStoredFoodAction)
.step(PathfindingAction)
.step(EatAction::default())
}
pub fn discover_food_and_offer_to_the_queen_steps() -> StepsBuilder {
Steps::build()
.label("DiscoverFood")
.step(SetPathToRandomOutsideAction)
.step(PathfindingAction)
.step(MapTransitionAction::exit())
.step(OutsideMapDiscoveringNewFoodAction::default())
.step(MapTransitionAction::enter())
.step(SetPathToQueenAction)
.step(PathfindingAction)
.step(OfferFoodDiscoveryToQueenAction)
} For example, when the DiscoverFood |
I think your best bet for this one is to create a Steps that forces completion of all the steps, but this whole thing pushes a little against the default model of "you will only continue doing things as long as they still make sense to you" |
I ran into the same confusion. I have two scorers that are multi step with Drink being one of the actions. If the drink quenches thirst over multiple frames then Drink Until thirst = x doesn’t work because another scorer comes in higher so the actor stops drinking. Then thirst quickly scores higher again and it goes back to drinking quickly. I think some of the confusion is the example “drink until” gives people the impression the actor will do nothing else until it’s drunk enough to reach the desired threshold. I assume the way to handle this is in the scorers to add some logic to the thirst scorer. Score thirst low until it hits say 0.8 BUT if the actor is currently drinking then even if thirst is lower score it higher. |
I've found out that
FirstToScore
behaves not how I thought it should.Here's a code snippet:
Situation:
MoveToFoodSource
part of the action,Thirsty
reaches the threshold of 0.8.Expected Behavior: Since the score calculation is
FirstToScore
, themove_and_eat
action is continuing execution because it reached the threshold first.Actual Behavior:
MoveToFoodSource
gets cancelled andMoveAndDrink
starts executing.In this exact case it this happens because
move_and_eat
is defined first in the thinker andmove_and_drink
second. It prioritizes the firstly defined action.The text was updated successfully, but these errors were encountered: