Package com.tnsai.invariants.rules
Class ConditionalRule
java.lang.Object
com.tnsai.invariants.rules.ConditionalRule
Represents a conditional transition rule like "DEAD if neighbors invalid input: '<' 2".
A ConditionalRule has:
effect- The target state/value when condition is true (e.g., "DEAD")condition- The boolean condition (e.g., "neighbors invalid input: '<' 2")currentStateCondition- Optional condition on current state (e.g., "state == ALIVE")description- Optional human-readable description (e.g., "underpopulation")
Rule Semantics
The rule "DEAD if neighbors invalid input: '<' 2 (underpopulation)" means:
IF neighbors invalid input: '<' 2 THEN result should be DEAD
For state transition rules (Game of Life), the implicit semantics are:
IF current state matches precondition AND condition is true THEN new state should be effect
- Author:
- TnsAI Team
-
Constructor Summary
ConstructorsConstructorDescriptionConditionalRule(String effect, String condition) Creates a simple rule without current state condition.ConditionalRule(String effect, String condition, String currentStateCondition, String description, String originalRule) Creates a ConditionalRule. -
Method Summary
-
Constructor Details
-
ConditionalRule
public ConditionalRule(String effect, String condition, String currentStateCondition, String description, String originalRule) Creates a ConditionalRule.- Parameters:
effect- the target state/value when condition is truecondition- the boolean condition expressioncurrentStateCondition- optional condition on current statedescription- optional human-readable descriptionoriginalRule- the original rule string
-
ConditionalRule
Creates a simple rule without current state condition.
-
-
Method Details
-
getEffect
-
getCondition
-
getCurrentStateCondition
-
getDescription
-
getOriginalRule
-
hasCurrentStateCondition
public boolean hasCurrentStateCondition() -
hasDescription
public boolean hasDescription() -
isStateTransitionRule
public boolean isStateTransitionRule()Checks if this is a state transition rule (effect is an enum-like value). State transitions are typically UPPER_CASE identifiers. -
isUnchangedRule
public boolean isUnchangedRule()Checks if this rule represents "no change" (e.g., "unchanged"). -
toString
-
equals
-
hashCode
public int hashCode()
-