/** * State-full hierarchical planning action selection mechanism * for virtual agents * * Frantisek Farka * 2011 * */ #ifndef _SF_HRP_ASM_H_ #define _SF_HRP_ASM_H_ //WTF #define null 0 #include #include #include #include "condition.hpp" #include "sf_hrp_plan.hpp" /** * Plan priority comparator */ struct CPlanComparator { /** * Compare priorities */ bool operator()( CSFHRPPlan* a, CSFHRPPlan* b) { return a->GetPriority() < b->GetPriority(); } }; /** * SF-HRP ASM * */ class CSFHRPASM { public: /* * Ctor */ CSFHRPASM(IEngineDescriptor*); /* * Dtor */ ~CSFHRPASM(); void SetCondition( int, bool); //condition enum, value int GetAction(); //returns enum with valid action /** * Activate single plan */ void Activate(CSFHRPPlan*); /** * Deactivate single plan */ void Deactivate(CSFHRPPlan*); /** * Register another plan */ void AddPlan( CSFHRPPlan*); /** * Register another plan */ void AddCondition( CCondition*); /** * Register another plan */ void RegisterElement( int, CElement*); private: typedef std::multimap< int, CElement*> elementMap; typedef std::vector< CSFHRPPlan* > planVector; typedef std::vector< CCondition* > conditionVector; typedef std::set< CSFHRPPlan*, CPlanComparator > planSet; /** * Hash map of * * serves passing condition values from engine to conditions */ elementMap m_conditionElements; /** * Children plans of ASM */ planVector m_plans; /** * Plans with holding releaser */ planSet m_holding; /** * active plan */ CSFHRPPlan* m_activePlan; /** * Engine descriptor */ IEngineDescriptor* m_engine; /** * Conditions * we make asm responsible for cleanup of conditions; */ conditionVector m_conditions; }; #endif //_SF_HRP_ASM_H_