interventions.InterventionApplier
- class interventions.InterventionApplier(state_manager, shift_reward)
Bases:
objectLightweight intervention applier for symbolic state updates.
This class parses intervention actions and applies them to a StateManager. For Scenario 1, it focuses on directional shifts (left, right, forward, back).
- Attributes:
state_manager: StateManager instance for tracking state changes. shift_reward: Reward bonus for successful shifts (currently unused).
- __init__(state_manager, shift_reward)
Initialize the intervention applier.
- Args:
state_manager: StateManager instance to apply interventions to. shift_reward: Reward bonus for successful shifts (default: 0.0).
Methods
__init__(state_manager, shift_reward)Initialize the intervention applier.
apply(obj, action)Apply an intervention to an object.
parse_action(action)Parse an action string into direction and magnitude.
- apply(obj, action)
Apply an intervention to an object.
Parses the action and applies it to the object via the StateManager.
- Args:
obj: Name of the object to intervene on (e.g., ‘1’, ‘2’, ‘3’). action: Action string (e.g., ‘left,0.005’).
- Returns:
- Tuple of (success, reward_delta):
success: True if intervention was successfully applied
reward_delta: Immediate reward from this intervention
- parse_action(action)
Parse an action string into direction and magnitude.
- Args:
action: Action string (e.g., ‘left,0.005’, ‘right,0.01’).
- Returns:
Tuple of (direction, magnitude), or (None, None) if parsing fails.
- Examples:
>>> parse_action('left,0.005') ('left', 0.005) >>> parse_action('forward,0.02') ('forward', 0.02)