feat: put PlannerNode member fns in planner.cpp
This commit is contained in:
		
							parent
							
								
									fdfde706e0
								
							
						
					
					
						commit
						971c2dd2ff
					
				|  | @ -31,6 +31,25 @@ Dictionary Goal::get_goal_state() const { | |||
| 
 | ||||
| #undef CLASSNAME // !Goal
 | ||||
| 
 | ||||
| PlannerNode PlannerNode::goal_node(WorldState const &goal)  { | ||||
|     return PlannerNode{ | ||||
|         goal, {}, {} | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| PlannerNode PlannerNode::new_node_along(Ref<Action> action) const { | ||||
|     PlannerNode new_node{ | ||||
|         action->prerequisites, | ||||
|         action->effects, | ||||
|         action, | ||||
|     }; | ||||
|     for(WorldProperty const &prop : this->state) | ||||
|         new_node.state.insert(prop.key, prop.value); | ||||
|     for(WorldProperty const &prop : this->open_requirements) | ||||
|         new_node.open_requirements.insert(prop.key, prop.value); | ||||
|     return new_node; | ||||
| } | ||||
| 
 | ||||
| void Planner::_bind_methods() { | ||||
| #define CLASSNAME Planner | ||||
|     GDPROPERTY_HINTED(actions, Variant::ARRAY, PROPERTY_HINT_ARRAY_TYPE, GDRESOURCETYPE(Action)); | ||||
|  |  | |||
|  | @ -49,24 +49,9 @@ struct PlannerNode { | |||
|     PlannerNode() = default; | ||||
|     PlannerNode(PlannerNode const &src) = default; | ||||
| 
 | ||||
|     static PlannerNode goal_node(WorldState goal) { | ||||
|         return PlannerNode{ | ||||
|             goal, {}, {} | ||||
|         }; | ||||
|     } | ||||
|     static PlannerNode goal_node(WorldState const &goal); | ||||
| 
 | ||||
|     PlannerNode new_node_along(Ref<Action> action) const { | ||||
|         PlannerNode new_node{ | ||||
|             action->prerequisites, | ||||
|             action->effects, | ||||
|             action, | ||||
|         }; | ||||
|         for(WorldProperty const &prop : this->state) | ||||
|             new_node.state.insert(prop.key, prop.value); | ||||
|         for(WorldProperty const &prop : this->open_requirements) | ||||
|             new_node.open_requirements.insert(prop.key, prop.value); | ||||
|         return new_node; | ||||
|     } | ||||
|     PlannerNode new_node_along(Ref<Action> action) const; | ||||
| }; | ||||
| 
 | ||||
| class Planner : public Node { | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Sara
						Sara