chore(naming): clarified names of PlannerNode maps/sets

This commit is contained in:
Sara 2024-04-21 15:34:38 +02:00
parent ae8b76bd0c
commit 36d681252b

View file

@ -13,8 +13,8 @@
#include <godot_cpp/variant/vector3.hpp>
namespace godot::goap {
typedef HashMap<PlannerNode, PlannerNode, PlannerNodeHasher> FromMap;
typedef HashMap<PlannerNode, float, PlannerNodeHasher> ScoreMap;
typedef HashMap<PlannerNode, PlannerNode, PlannerNodeHasher> NodeNodeMap;
typedef HashMap<PlannerNode, float, PlannerNodeHasher> NodeScoreMap;
typedef HashSet<PlannerNode, PlannerNodeHasher> NodeSet;
void Goal::_bind_methods() {
@ -69,7 +69,7 @@ void Planner::_enter_tree() {
this->actor = Object::cast_to<CharacterActor>(this->get_parent());
}
static Vector<Ref<Action>> trace_path(FromMap &map, PlannerNode &end) {
static Vector<Ref<Action>> trace_path(NodeNodeMap &map, PlannerNode &end) {
Vector<Ref<Action>> edges{};
PlannerNode node{end};
while(node.last_edge.is_valid()) {
@ -91,10 +91,10 @@ Vector<Ref<Action>> Planner::make_plan() {
// ordered list of all nodes still being considered
Vector<PlannerNode> open{PlannerNode::goal_node(goal->goal_state)};
PlannerNode first = open.get(0);
FromMap from{}; // mapping states to the previous in the path
ScoreMap dist_traveled{}; // mapping states to the shortest found distance from start
NodeNodeMap from{}; // mapping states to the previous in the path
NodeScoreMap dist_traveled{}; // mapping states to the shortest found distance from start
dist_traveled.insert(first, 0);
ScoreMap best_guess{}; // mapping states to the best guess of the distance to the goal
NodeScoreMap best_guess{}; // mapping states to the best guess of the distance to the goal
best_guess.insert(first, first.open_requirements.size());
PlannerNode current{}; // state we're checking for neighbours or completion
while(!open.is_empty()) {
@ -123,7 +123,7 @@ Vector<Ref<Action>> Planner::make_plan() {
}
}
}
UtilityFunctions::push_warning("Failed to find a path satisfying goal");
UtilityFunctions::push_warning("Failed to find a plan satisfying goal");
this->plan = {};
return this->plan;
}