ai.cpp now has a nice easy to use API for loading and running the GOAP things.
This commit is contained in:
parent
a079f882df
commit
b2c1b220ac
4 changed files with 458 additions and 27 deletions
22
ai.hpp
22
ai.hpp
|
@ -5,6 +5,7 @@
|
|||
#include <limits>
|
||||
#include <optional>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "config.hpp"
|
||||
|
||||
namespace ai {
|
||||
constexpr const int SCORE_MAX = std::numeric_limits<int>::max();
|
||||
|
@ -30,7 +31,6 @@ namespace ai {
|
|||
|
||||
void needs(int name, bool val);
|
||||
void effect(int name, bool val);
|
||||
void load(nlohmann::json &profile, nlohmann::json& config);
|
||||
|
||||
bool can_effect(State& state);
|
||||
State apply_effect(State& state);
|
||||
|
@ -61,6 +61,26 @@ namespace ai {
|
|||
int distance_to_goal(State& from, State& to);
|
||||
|
||||
std::optional<Script> plan_actions(std::vector<Action>& actions, State& start, State& goal);
|
||||
|
||||
struct AIManager {
|
||||
nlohmann::json profile;
|
||||
|
||||
std::unordered_map<std::string, Action> actions;
|
||||
std::unordered_map<std::string, State> states;
|
||||
std::unordered_map<std::string, std::vector<Action>> scripts;
|
||||
};
|
||||
|
||||
void init();
|
||||
|
||||
Action config_action(nlohmann::json& profile, nlohmann::json& config);
|
||||
State config_state(nlohmann::json& profile, nlohmann::json& config);
|
||||
|
||||
int state_id(std::string name);
|
||||
State load_state(std::string state_name);
|
||||
Action load_action(std::string action_name);
|
||||
std::vector<Action> load_script(std::string script_name);
|
||||
|
||||
std::optional<Script> plan(std::string script_name, State start, State goal);
|
||||
}
|
||||
|
||||
template<> struct std::hash<ai::Action> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue