The basic idea of using GOAP to figure out if combined items will produce a valid ritual, and what kind of things the ritual does, mostly works.
This commit is contained in:
parent
7984540c0c
commit
eeea3c794f
2 changed files with 24 additions and 16 deletions
|
@ -3,17 +3,20 @@
|
|||
"does_damage": 0,
|
||||
"has_spikes": 1,
|
||||
"has_magick": 2,
|
||||
"is_complete": 3
|
||||
"does_physical": 3,
|
||||
"does_magick": 4,
|
||||
"is_complete": 5
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"name": "pierce_type",
|
||||
"cost": 1000,
|
||||
"cost": 0,
|
||||
"needs": {
|
||||
"is_complete": false,
|
||||
"has_spikes": true
|
||||
},
|
||||
"effects": {
|
||||
"does_physical": true,
|
||||
"does_damage": true
|
||||
}
|
||||
},
|
||||
|
@ -25,6 +28,7 @@
|
|||
"has_magick": true
|
||||
},
|
||||
"effects": {
|
||||
"does_magick": true,
|
||||
"does_damage": true
|
||||
}
|
||||
},
|
||||
|
@ -41,12 +45,16 @@
|
|||
],
|
||||
"states": {
|
||||
"initial": {
|
||||
"has_spikes": false,
|
||||
"has_magick": false,
|
||||
"does_damage": false,
|
||||
"is_complete": false,
|
||||
"has_spikes": false,
|
||||
"has_magick": false
|
||||
"does_magick": false,
|
||||
"does_physical": false
|
||||
},
|
||||
"final": {
|
||||
"does_magick": true,
|
||||
"does_physical": true,
|
||||
"does_damage": true,
|
||||
"is_complete": true
|
||||
}
|
||||
|
|
|
@ -6,16 +6,21 @@
|
|||
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), goal(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;
|
||||
|
@ -35,15 +40,6 @@ struct RitualAI {
|
|||
};
|
||||
|
||||
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");
|
||||
|
||||
|
@ -54,14 +50,18 @@ TEST_CASE("prototype combat system ideas", "[combat]") {
|
|||
|
||||
ritual.set_state("has_spikes", true);
|
||||
ritual.update();
|
||||
|
||||
fmt::println("------------ TEST WILL DO PIERCE");
|
||||
ritual.dump();
|
||||
REQUIRE(ritual.will_do("pierce_type"));
|
||||
|
||||
ritual.reset();
|
||||
ritual.set_state("has_magick", true);
|
||||
ritual.set_state("has_spikes", true);
|
||||
ritual.update();
|
||||
|
||||
fmt::println("------------ TEST WILL DO MAGICK TOO");
|
||||
ritual.dump();
|
||||
REQUIRE(ritual.will_do("magick_type"));
|
||||
|
||||
ritual.plan.script.pop_front();
|
||||
REQUIRE(ritual.will_do("pierce_type"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue