Rituals are more or less sorted out in theory, and they helped find a cycle in the GOAP algorithm that I'm detecting/preventing.
parent
8368d2e751
commit
49531ba148
@ -0,0 +1,23 @@ |
|||||||
|
#include "rituals.hpp" |
||||||
|
#include "ai_debug.hpp" |
||||||
|
|
||||||
|
void RitualAI::reset() { |
||||||
|
start = original; |
||||||
|
} |
||||||
|
|
||||||
|
bool RitualAI::will_do(std::string name) { |
||||||
|
ai::check_valid_action(name, "RitualAI::is_able_to"); |
||||||
|
return plan.script[0].name == name; |
||||||
|
} |
||||||
|
|
||||||
|
void RitualAI::set_state(std::string name, bool setting) { |
||||||
|
ai::set(start, name, setting); |
||||||
|
} |
||||||
|
|
||||||
|
void RitualAI::update() { |
||||||
|
plan = ai::plan(script, start, goal); |
||||||
|
} |
||||||
|
|
||||||
|
void RitualAI::dump() { |
||||||
|
ai::dump_script(script, start, plan.script); |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
#pragma once |
||||||
|
#include "ai.hpp" |
||||||
|
|
||||||
|
struct RitualAI { |
||||||
|
std::string script; |
||||||
|
ai::State start; |
||||||
|
ai::State original; |
||||||
|
ai::State goal; |
||||||
|
ai::ActionPlan plan; |
||||||
|
|
||||||
|
RitualAI(std::string script, ai::State start, ai::State goal) : |
||||||
|
script(script), start(start), original(start), goal(goal) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
RitualAI() {}; |
||||||
|
|
||||||
|
void reset(); |
||||||
|
bool will_do(std::string name); |
||||||
|
void set_state(std::string name, bool setting); |
||||||
|
void update(); |
||||||
|
void dump(); |
||||||
|
}; |
@ -1,10 +1,10 @@ |
|||||||
#include "stats.hpp" |
#include "stats.hpp" |
||||||
#include <fmt/core.h> |
#include <fmt/core.h> |
||||||
|
|
||||||
void Stats::dump() |
void Stats::dump(std::string msg) |
||||||
{ |
{ |
||||||
fmt::println("sum: {}, sumsq: {}, n: {}, " |
fmt::println("{}: sum: {}, sumsq: {}, n: {}, " |
||||||
"min: {}, max: {}, mean: {}, stddev: {}", |
"min: {}, max: {}, mean: {}, stddev: {}", |
||||||
sum, sumsq, n, min, max, mean(), |
msg, sum, sumsq, n, min, max, mean(), |
||||||
stddev()); |
stddev()); |
||||||
} |
} |
||||||
|
@ -1,43 +1,7 @@ |
|||||||
#include <catch2/catch_test_macros.hpp> |
#include <catch2/catch_test_macros.hpp> |
||||||
#include <iostream> |
#include <iostream> |
||||||
#include "ai.hpp" |
#include "rituals.hpp" |
||||||
#include "ai_debug.hpp" |
|
||||||
|
|
||||||
struct RitualAI { |
|
||||||
std::string script; |
|
||||||
ai::State start; |
|
||||||
ai::State original; |
|
||||||
ai::State goal; |
|
||||||
ai::ActionPlan plan; |
|
||||||
|
|
||||||
RitualAI(std::string script, ai::State start, ai::State goal) : |
|
||||||
script(script), start(start), original(start), goal(goal) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
RitualAI() {}; |
|
||||||
|
|
||||||
void reset() { |
|
||||||
start = original; |
|
||||||
} |
|
||||||
|
|
||||||
bool will_do(std::string name) { |
|
||||||
ai::check_valid_action(name, "RitualAI::is_able_to"); |
|
||||||
return plan.script[0].name == name; |
|
||||||
} |
|
||||||
|
|
||||||
void set_state(std::string name, bool setting) { |
|
||||||
ai::set(start, name, setting); |
|
||||||
} |
|
||||||
|
|
||||||
void update() { |
|
||||||
plan = ai::plan(script, start, goal); |
|
||||||
} |
|
||||||
|
|
||||||
void dump() { |
|
||||||
dump_script(script, start, plan.script); |
|
||||||
} |
|
||||||
}; |
|
||||||
|
|
||||||
TEST_CASE("prototype combat system ideas", "[combat]") { |
TEST_CASE("prototype combat system ideas", "[combat]") { |
||||||
ai::reset(); |
ai::reset(); |
Loading…
Reference in new issue