babylon.engine.event_evaluator
Event Template evaluation engine.
Provides pure functions to evaluate EventTemplates against WorldState graphs. This is NOT a System - it’s a utility module used by Systems or the engine.
Sprint: Event Template System
Functions
|
Aggregate values and compare to threshold. |
|
Calculate a graph-level aggregate metric. |
|
Apply comparison operator. |
|
Evaluate an EdgeCondition against edges. |
|
Evaluate a GraphCondition against graph-level metrics. |
|
Evaluate a NodeCondition against matching nodes. |
|
Evaluate a PreconditionSet against the graph. |
|
Evaluate an EventTemplate against the current graph state. |
|
Filter nodes based on NodeFilter criteria. |
|
Get nodes that match the template's node conditions. |
|
Get a value from nested dict using dot notation. |
- babylon.engine.event_evaluator.evaluate_template(template, graph, current_tick)[source]
Evaluate an EventTemplate against the current graph state.
- Parameters:
template (
EventTemplate) – The EventTemplate to evaluate.graph (
GraphProtocol) – Graph representing WorldState.current_tick (
int) – Current simulation tick.
- Return type:
- Returns:
The matching Resolution if preconditions met and a resolution matches, None otherwise.
- babylon.engine.event_evaluator.evaluate_preconditions(preconditions, graph)[source]
Evaluate a PreconditionSet against the graph.
- Parameters:
preconditions (
PreconditionSet) – Set of conditions to evaluate.graph (
GraphProtocol) – Graph to evaluate against.
- Return type:
- Returns:
True if preconditions are satisfied, False otherwise.
- babylon.engine.event_evaluator.evaluate_node_condition(condition, graph)[source]
Evaluate a NodeCondition against matching nodes.
- Parameters:
condition (
NodeCondition) – The node condition to evaluate.graph (
GraphProtocol) – Graph to evaluate against.
- Return type:
- Returns:
True if condition is satisfied, False otherwise.
- babylon.engine.event_evaluator.evaluate_edge_condition(condition, graph)[source]
Evaluate an EdgeCondition against edges.
- Parameters:
condition (
EdgeCondition) – The edge condition to evaluate.graph (
GraphProtocol) – Graph to evaluate against.
- Return type:
- Returns:
True if condition is satisfied, False otherwise.
- babylon.engine.event_evaluator.evaluate_graph_condition(condition, graph)[source]
Evaluate a GraphCondition against graph-level metrics.
- Parameters:
condition (
GraphCondition) – The graph condition to evaluate.graph (
GraphProtocol) – Graph to evaluate against.
- Return type:
- Returns:
True if condition is satisfied, False otherwise.
- babylon.engine.event_evaluator.calculate_graph_metric(graph, metric)[source]
Calculate a graph-level aggregate metric.
- Parameters:
graph (
GraphProtocol) – Graph to analyze.metric (
str) – Name of the metric to calculate.
- Return type:
- Returns:
The calculated metric value.
- babylon.engine.event_evaluator.filter_nodes(graph, node_filter)[source]
Filter nodes based on NodeFilter criteria.
- Parameters:
graph (
GraphProtocol) – Graph containing nodes.node_filter (
NodeFilter|None) – Filter criteria, or None for all nodes.
- Return type:
- Returns:
List of node IDs matching the filter.
- babylon.engine.event_evaluator.get_nested_value(data, path)[source]
Get a value from nested dict using dot notation.
Follows the same pattern as TriggerCondition._get_nested_value.
- babylon.engine.event_evaluator.compare(value, operator, threshold)[source]
Apply comparison operator.
- babylon.engine.event_evaluator.aggregate_and_compare(values, aggregation, operator, threshold)[source]
Aggregate values and compare to threshold.
- babylon.engine.event_evaluator.get_matching_nodes_for_resolution(template, graph)[source]
Get nodes that match the template’s node conditions.
Used for ${node_id} substitution in resolution effects.
- Parameters:
template (
EventTemplate) – The EventTemplate being resolved.graph (
GraphProtocol) – Graph to search.
- Return type:
- Returns:
List of node IDs that satisfy the node conditions.