feat: added debug prints to planner and actor world state

This commit is contained in:
Sara 2024-07-28 11:43:04 +02:00
parent 0bb0b26d3e
commit 4ba6869a30
2 changed files with 14 additions and 0 deletions

View file

@ -1,4 +1,7 @@
#include "actor_world_state.hpp"
#ifdef DEBUG_ENABLED
#include "godot_cpp/variant/utility_functions.hpp"
#endif
namespace goap {
void ActorWorldState::_bind_methods() {
@ -10,6 +13,11 @@ bool ActorWorldState::check_property_match(WorldProperty const &property) {
}
gd::Variant ActorWorldState::get_world_property(gd::String world_prop_name) {
#ifdef DEBUG_ENABLED
if(!this->has_method("get_" + world_prop_name)) {
gd::UtilityFunctions::push_error("tried to get nonexistent property ", world_prop_name);
}
#endif
return this->call("get_" + world_prop_name);
}
}

View file

@ -190,8 +190,14 @@ bool Planner::does_action_contribute(Action const *action, WorldStateNode const
Plan Planner::unroll_plan(WorldStateNode const &start_node, NodeMap const &from) {
Plan plan{};
WorldStateNode node{start_node};
#if DEBUG_ENABLED
gd::UtilityFunctions::print("plan (", this->get_path(), "):");
#endif
while(node.last_action != nullptr) {
plan.push_back(node.last_action);
#if DEBUG_ENABLED
gd::UtilityFunctions::print(" (", plan.size(), ") ", node.last_action->get_class());
#endif
node = from.get(node);
}
return plan;