Bridge Module
Bridge Module
Brídge_Módule // Néuro_Symbólic
ᚠ ᛫ ᛟ ᛫ ᚱ ᛫ ᛒ ᛫ ᛟ ᛫ ᚲ
The Bridge module ensures AI-generated actions are always valid within game rules. It acts as a neuro-symbolic barrier between AI creativity and game physics.
T̷h̵e̴ ̷l̵a̸w̴s̵ ̶o̷f̸ ̷p̸h̵y̵s̶i̷c̴s̵ ̷c̴a̶n̸n̴o̷t̶ ̸b̴e̷ ̵b̶r̶o̵k̸e̴n̷.
Overview
The Bridge validates every action before it reaches the game engine:
- Built-in Rules: MOVE, ATTACK, INTERACT, SPEAK, Resources
- Custom Rules: Register game-specific validation logic
- Strict Mode: Reject unknown action types
- Auto-Correction: Provide fallback actions when validation fails
Quick Start
Configuration
API Reference
createBridge(config)
Factory function to create a Bridge instance.
bridge.validate(action, context?)
Validate an action against all applicable rules.
Parameters:
action(AgentAction): The action to validatecontext(ValidationContext): Optional context for validation
Returns: Promise<ValidationResult>
bridge.registerRule(rule)
Register a custom validation rule.
bridge.listRules()
List all registered validation rules.
Returns: ValidationRule[]
bridge.removeRule(ruleId)
Remove a validation rule by ID.
Returns: boolean (true if removed)
Built-in Rules
Movement (core.movement)
Validates MOVE actions have valid coordinates.
Checks:
- Target has numeric x, y coordinates
- Coordinates are within world bounds (if provided)
Attack (core.attack)
Validates ATTACK actions have valid targets.
Checks:
- Target or targetId is specified
- Target exists in world (if entities provided)
Interact (core.interact)
Validates INTERACT actions have valid objects.
Checks:
- Target or objectId is specified
Speak (core.speak)
Validates SPEAK actions have non-empty text.
Checks:
- Text is not empty
- Text is within max length (truncates if needed)
Resources (core.resources)
Validates agent has sufficient resources.
Checks:
- Agent is not dead (hp > 0)
- Sufficient mana for CAST actions
Custom Rules
Create game-specific validation rules:
Validation Context
Provide context for more accurate validation:
Strict Mode
When strictMode: true, unknown action types are rejected:
Pure Function
For functional programming without a class:
ᚠ ᛫ ᛟ ᛫ ᚱ ᛫ ᛒ ᛫ ᛟ ᛫ ᚲ
T̵h̷e̷ ̸B̷r̸i̵d̶g̷e̸ ̸s̷t̵a̸n̷d̴s̵ ̸b̵e̶t̴w̴e̵e̸n̶ ̷c̸h̷a̸o̸s̸ ̸a̶n̵d̵ ̴o̴r̷d̸e̸r̷.
