#!/usr/bin/env python3
"""
Hierarchical Planning - Multi-level goal decomposition
"""

class HierarchicalPlanner:
    def __init__(self):
        print("Initializing hierarchical planner...")
        self.methods = self._define_methods()
        print("✅ Hierarchical planning ready!")
    
    def _define_methods(self):
        return {
            'make_dinner': [
                ['prepare_ingredients', 'cook_food', 'serve_food']
            ],
            'prepare_ingredients': [
                ['get_vegetables', 'wash_vegetables', 'cut_vegetables']
            ],
            'cook_food': [
                ['heat_pan', 'add_ingredients', 'stir']
            ],
            'serve_food': [
                ['get_plates', 'plate_food']
            ]
        }
    
    def decompose(self, task):
        if task not in self.methods:
            return [task]
        plan = []
        for method in self.methods[task][0]:
            plan.extend(self.decompose(method))
        return plan
    
    def plan(self, goal):
        return self.decompose(goal)

def test_hierarchical():
    print("\n" + "="*70)
    print("TESTING HIERARCHICAL PLANNING")
    print("="*70)
    hp = HierarchicalPlanner()
    plan = hp.plan('make_dinner')
    print(f"\nGoal: make_dinner")
    print(f"Plan: {plan}")
    print(f"Steps: {len(plan)}")
    if len(plan) >= 8:
        print("✅ Hierarchical planning working!")
        return True
    return False

def main():
    if test_hierarchical():
        print("\n✅ CAPABILITY #16 COMPLETE")

if __name__ == "__main__":
    main()
