BREAKING: First idea for the combat system but there's a bug in goap where I'm not removing closed parts or something like that.
This commit is contained in:
parent
75db188dc6
commit
63f032ff12
8 changed files with 130 additions and 4 deletions
67
tests/combat.cpp
Normal file
67
tests/combat.cpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <iostream>
|
||||
#include "ai.hpp"
|
||||
#include "ai_debug.hpp"
|
||||
|
||||
struct RitualAI {
|
||||
std::string script;
|
||||
ai::State start;
|
||||
ai::State goal;
|
||||
ai::ActionPlan plan;
|
||||
|
||||
RitualAI(std::string script, ai::State start, ai::State goal) :
|
||||
script(script), start(start), goal(goal)
|
||||
{
|
||||
}
|
||||
|
||||
RitualAI() {};
|
||||
|
||||
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]") {
|
||||
// as the player picks up items they go in the invetory
|
||||
// and they player has little "bags" they can put items
|
||||
// in that combine the items into rituals. How the items
|
||||
// combine is controlled by the GOAP algorithm but tailored
|
||||
// to item combinations that produce effects
|
||||
|
||||
// probably need to use the code in ai.cpp in a different
|
||||
// system for the ritual loading stuff
|
||||
//
|
||||
ai::reset();
|
||||
ai::init("assets/rituals.json");
|
||||
|
||||
auto start = ai::load_state("initial");
|
||||
auto goal = ai::load_state("final");
|
||||
|
||||
RitualAI ritual("actions", start, goal);
|
||||
|
||||
ritual.set_state("has_spikes", true);
|
||||
ritual.update();
|
||||
|
||||
ritual.dump();
|
||||
REQUIRE(ritual.will_do("pierce_type"));
|
||||
|
||||
ritual.set_state("has_magick", true);
|
||||
ritual.update();
|
||||
|
||||
fmt::println("------------ TEST WILL DO MAGICK TOO");
|
||||
ritual.dump();
|
||||
REQUIRE(ritual.will_do("magick_type"));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue