Hi everyone.
I am working on system where I use defrules to push actions to a "requested actions queue" into my C++ code.
But I have a strange problem I don't understand.
To give more info, this is the rule:
; Default agent wander by default
(defrule MAIN::barbarian_agent_wander_around
(not (exists (has_order))) ; There is not any higher priority order
(faction (type ?faction_type))
(npc_agent (id ?agent_id) (faction_type ?faction_type))
(not (exists (current_action ?any_action_id ?agent_id ?any_status)))
=>
(bind ?action_id (udf_generate_unique_id)) ; UDF to generate unique action ID
(udf_request_action ?action_id WANDER ?agent_id) ; UDF to push an action request to the request queue
)
So, the idea behind this, is that the first tick, the system will call udf_request_action function, because the fact (current_action ?any_action_id ?agent_id ?any_status) won't be there.
Once I have an action in the queue, after the update of the rule based system, I create and execute the action, so during the execution, I assert the fact (current_action ?any_action_id ?agent_id ?any_status).
My expected behavior would be that, once I have already that fact in the database, the defrule wouldn't fire anymore, because of the (not (exist ...)) that is checking if there is a current action.
For some reason this is not happening, any idea of what I am doing wrong?
Cheers,
Jose