feat: added debug prints to planner and actor world state
This commit is contained in:
parent
0bb0b26d3e
commit
4ba6869a30
|
@ -1,4 +1,7 @@
|
||||||
#include "actor_world_state.hpp"
|
#include "actor_world_state.hpp"
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
#include "godot_cpp/variant/utility_functions.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace goap {
|
namespace goap {
|
||||||
void ActorWorldState::_bind_methods() {
|
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) {
|
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);
|
return this->call("get_" + world_prop_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 Planner::unroll_plan(WorldStateNode const &start_node, NodeMap const &from) {
|
||||||
Plan plan{};
|
Plan plan{};
|
||||||
WorldStateNode node{start_node};
|
WorldStateNode node{start_node};
|
||||||
|
#if DEBUG_ENABLED
|
||||||
|
gd::UtilityFunctions::print("plan (", this->get_path(), "):");
|
||||||
|
#endif
|
||||||
while(node.last_action != nullptr) {
|
while(node.last_action != nullptr) {
|
||||||
plan.push_back(node.last_action);
|
plan.push_back(node.last_action);
|
||||||
|
#if DEBUG_ENABLED
|
||||||
|
gd::UtilityFunctions::print(" (", plan.size(), ") ", node.last_action->get_class());
|
||||||
|
#endif
|
||||||
node = from.get(node);
|
node = from.get(node);
|
||||||
}
|
}
|
||||||
return plan;
|
return plan;
|
||||||
|
|
Loading…
Reference in a new issue