Add Tower of Hanoi domain#12
Open
j-vaught wants to merge 4 commits into
Open
Conversation
Adds a fully parameterized Tower of Hanoi domain (hanoi.<num_disks>.<num_pegs>) supporting arbitrary disk and peg counts.
7f5645f to
6384dfd
Compare
Equation Simplification: polynomial expressions with combine/swap/remove. Word Ladder: 4-letter word transformations via single-char substitution. Circuit Minimization: boolean SOP expression simplification via QM.
Removed three domains that were either trivially solvable (equation) or less compelling for demonstrating learned heuristics. Added a simplified retrosynthesis domain where molecules (6-position carbon chains with 8 functional groups and single/double bonds) must be transformed through valid chemical reactions. Multi-step reaction dependencies create genuine search complexity that cannot be solved by greedy approaches.
Reactions now target the most reactive eligible position instead of a player-chosen one, creating tight coupling between positions. Added protecting groups, global reagent incompatibilities, and reactivity-based site selection. Positions are no longer independently solvable -- the optimal sequence depends on the entire molecular state.
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.
Add Tower of Hanoi domain
Adds a fully parameterized Tower of Hanoi domain supporting arbitrary disk and peg counts via
hanoi.<num_disks>.<num_pegs>.Design
State:
uint8array of lengthnum_diskswherestate[i]= peg of diski(disk 0 = largest, disk N-1 = smallest).Actions:
K*(K-1)directed peg-to-peg moves.get_state_actionsoverrides theActsEnumFixeddefault to filter to only valid moves per state (source peg non-empty, destination either empty or topped by a larger disk).Mixins:
ActsEnumFixedwithget_state_actionsoverride for validity filteringGoalStartRevWalkableActsRevfor reverse-walk problem instance generationGoalFixedforGoalSampleableinterfaceHasFlatSGInwith one-hot depth K (input size =num_disks * num_pegs)StateGoalVizablewith peg-stack renderingStringToActfor interactive CLI solving ('F T'or'FT')Implementation details:
_validity_batchvectorizes the move-legality check across batches using(on_peg * [1..N]).max() - 1to find the top disk per pegnext_stategroups states by action and applies valid moves via numpy fancy indexingrev_actionswaps source/destination pegs (algebraically guaranteed valid after a forward move)Usage
Scale to more disks or pegs by changing the domain argument (e.g.
hanoi.8.3,hanoi.4.4,hanoi.20.7).Experimental results
Trained and evaluated on three configurations. All worst-case instances (all disks on peg 0, goal on last peg) solved optimally.
The 4-peg model independently discovered the Frame-Stewart optimal strategy.