Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

FirstToScore cancels ongoing action when different action passes threshold #73

@ZilvinasAbr

Description

@ZilvinasAbr

I've found out that FirstToScore behaves not how I thought it should.

Here's a code snippet:

        // Define a multistep action of moving and drinking
        let move_and_drink = Steps::build()
            .label("MoveAndDrink")
            .step(MoveToWaterSource)
            .step(Drink);

        // Define a multistep action of moving and eating
        let move_and_eat = Steps::build()
            .label("MoveAndEat")
            .step(MoveToFoodSource)
            .step(Eat);

        // Define the thinker
        let thinker = Thinker::build()
            .label("Thinker")
            .picker(FirstToScore { threshold: 0.8 })
            .when(Hungry, move_and_eat)
            .when(Thirsty, move_and_drink);

Situation:

  1. Thirsty is 0.6, Hungry is 0.8
  2. Thinker starts executing move and eat action.
  3. Meanwhile doing the MoveToFoodSource part of the action, Thirsty reaches the threshold of 0.8.

Expected Behavior: Since the score calculation is FirstToScore, the move_and_eat action is continuing execution because it reached the threshold first.

Actual Behavior: MoveToFoodSource gets cancelled and MoveAndDrink starts executing.

In this exact case it this happens because move_and_eat is defined first in the thinker and move_and_drink second. It prioritizes the firstly defined action.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions