Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Node.h
Go to the documentation of this file.
1
9#pragma once
10
11#include "Action.h"
12#include "WorldState.h"
13
14namespace Divide {
15
16namespace goap {
17 struct Node {
18 static I32 last_id_; // a static that lets us assign incrementing, unique IDs to nodes
19
20 WorldState ws_; // The state of the world at this node.
21 I32 id_; // the unique ID of this node
22 I32 parent_id_; // the ID of this node's immediate predecessor
23 I32 g_; // The A* cost from 'start' to 'here'
24 I32 h_; // The estimated remaining cost to 'goal' form 'here'
25 const Action* action_; // The action that got us here (for replay purposes)
26
27 Node() noexcept;
28 Node(const WorldState& state, I32 g, I32 h, I32 parent_id, const Action* action);
29
30 // F -- which is simply G+H -- is autocalculated
31 inline I32 f() const noexcept { return g_ + h_; }
32
33// /**
34// Less-than operator, needed for keeping Nodes sorted.
35// @param other the other node to compare against
36// @return true if this node is less than the other (using F)
37// */
38// bool operator<(const Node& other);
39
40 [[nodiscard]] string toString( ) const;
41
42 };
43
44 bool operator<(const Node& lhs, const Node& rhs) noexcept;
45} //namespace goap
46} //namespace Divide
A node is any point on the path between staring point and ending point (inclusive)
bool operator<(const Node &lhs, const Node &rhs) noexcept
Definition: Node.cpp:27
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
int32_t I32
const Action * action_
Definition: Node.h:25
I32 parent_id_
Definition: Node.h:22
Node() noexcept
Definition: Node.cpp:12
string toString() const
Definition: Node.cpp:35
WorldState ws_
Definition: Node.h:20
I32 f() const noexcept
Definition: Node.h:31
static I32 last_id_
Definition: Node.h:18