Daniel Souza - 2020-03-23

If you dispatch a goal with recur condition, this condition will not listen to the belief if the goal still inprocess. It is required to change outside the execution of the same one.

@Agent
public class testeBDI {

    @Belief
    protected int change = 0;

    @Goal(recur=true)
    public class FactChangedGoal {

        @GoalRecurCondition
        public boolean recur(@Event(type=ChangeEvent.FACTCHANGED,value="change") ChangeInfo change) {
            System.out.println("FactChangedGoal :: Recur :: ChangeInfo: " + change);
            return true;
        }
    }

    @Plan(trigger=@Trigger(goals= {FactChangedGoal.class}))
    public void achieveFive() {
        if(change < 5) {
            System.out.println(change + " < 5");
            change++;
            throw new PlanFailureException("change not achieved 5");
        }
        System.out.println("change achieved 5");
    }

}

when dispatching the above goal, it will only prints: 0 < 5.

What can I do to trigger the goal again when I need to perform a belief change inside the executing plan of the same goal?