Action Selection Knob Building#463
Open
K1rubel wants to merge 7 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the action-selection knob-building sub-system from C++ MOSES into MeTTa. It enables representation building for action sequences and conditional behaviors, decorates them with Action Subtree Knobs (ASKs).
Description
Action Classification: Classified structural action operators (such as and_seq, action_bool_if, or_seq, seq_exec, action_while, etc.) and distinguished them from user-defined domain actions.
Untyped Validation: Introduced helper functions like isDomainAction / isBuiltinAction to treat caller-supplied action lists as the source of truth for primitive actions in MeTTa's untyped environment.
Designed and registered two constructors for wrapping action subtrees into discrete knobs:
Action-Subtree ASK (actionSubtreeKnob): Holds a list of alternate action permutations. Multiplicity is set to$N + 1$ (where index 0 represents the absent choice, and indices 1..N correspond to selected permutations).
Simple-Action ASK (simpleActionSubtreeKnob): Wraps a single built-in action subtree. Multiplicity is set to$2$ (index 0 is absent, index 1 is present).
Implemented the C++ recursive knob-building algorithm (build_knobs::build_action) with the probability threshold $p = 80:
Sequences (and_seq):
Root sequence blocks are decorated with action choice knobs (80% probability).
Existing sequence children are mapped recursively: built-in actions are wrapped in simple toggle knobs (20% probability) or sequence wrapper nodes (80% probability).
An empty action sequence wrapper is appended at the end of the sequence block with a 20% probability.
Conditionals (action_bool_if):
Ordered Pair Mapping: Implemented sampleActionPerms and actionPairFromIndex to sample from the ordered action-pair space of size$N \times (N - 1)$ using lazyRandomSelector.
Conditional Permutations: Paired random perceptions with action choices to produce conditional permutation blocks of the format: (action_bool_if $perception $actA $actB).
Extended the appendTo dispatcher inside lsk.metta to support unrolling of action selection knobs during candidate scoring:
Toggle Knobs (Simple-Action): Setting 0 prunes the branch; setting 1 appends the subtree and continues recursive candidate unrolling down the target path.
Choice Knobs (Action-Subtree): Setting 0 prunes the branch; settings 1..N append the selected permutation and stop recursion at that node.
Canonization (actionCanonize): Ensures sequence uniformity by wrapping non-sequential roots under a default and_seq node before knob building.
Pruning (actionCleanup): Traverses the tree bottom-up (post-order) and removes childless structural operators (and_seq, or_seq, seq_exec), replacing them with null vertices.
Wired the action path into the unified buildKnobs entry point:
Types of changes
Checklist:
To Follow this
Frame the game strategy evolution as an action selection problem and use action selection operators to evolve a game strategy.