Package com.tnsai.planning
Class ConditionEvaluator
java.lang.Object
com.tnsai.planning.ConditionEvaluator
Evaluates condition expressions against a state (belief) map.
Supports a simple expression language for goal conditions and action preconditions:
- Comparison:
==,!=,>,>=,<,<= - Logical:
&&,||,! - Literals:
true,false, numbers, strings
Examples
Map<String, Object> state = Map.of("health", 80, "state", "ALIVE");
ConditionEvaluator.evaluate("health > 50", state); // true
ConditionEvaluator.evaluate("state == ALIVE", state); // true
ConditionEvaluator.evaluate("health > 0 && health < 100", state); // true
- Author:
- TnsAI Team
-
Method Summary
-
Method Details
-
evaluate
Evaluates a condition expression against the given state.A variable the state does not hold is unknown rather than null, and a condition whose value turns on an unknown is not satisfied: negating it does not satisfy it either.
- Parameters:
condition- expression to evaluatestate- current state (belief map)- Returns:
- true if condition is satisfied
-
applyEffects
Parses and applies postcondition effects to a state map.Postcondition syntax:
"variable = value"or"var1 = val1, var2 = val2"- Parameters:
postcondition- effect expressionstate- state to modify (mutable)
-