GOAP now uses only bit operations to do its thing.
This commit is contained in:
parent
01525388ec
commit
3d8a2d4342
4 changed files with 54 additions and 41 deletions
|
@ -1,6 +1,7 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include "dbc.hpp"
|
||||
#include "goap.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace dbc;
|
||||
using namespace ailol;
|
||||
|
@ -23,8 +24,8 @@ TEST_CASE("worldstate works", "[goap]") {
|
|||
goal[ENEMY_DEAD] = true;
|
||||
|
||||
Action move_closer("move_closer", 10);
|
||||
move_closer.preconds[ENEMY_IN_RANGE] = false;
|
||||
move_closer.effects[ENEMY_IN_RANGE] = true;
|
||||
move_closer.set_precond(ENEMY_IN_RANGE, false);
|
||||
move_closer.set_effect(ENEMY_IN_RANGE, true);
|
||||
|
||||
REQUIRE(move_closer.can_effect(start));
|
||||
auto after_move_state = move_closer.apply_effect(start);
|
||||
|
@ -37,9 +38,9 @@ TEST_CASE("worldstate works", "[goap]") {
|
|||
REQUIRE(distance_to_goal(start, after_move_state) == 1);
|
||||
|
||||
Action kill_it("kill_it", 10);
|
||||
kill_it.preconds[ENEMY_IN_RANGE] = true;
|
||||
kill_it.preconds[ENEMY_DEAD] = false;
|
||||
kill_it.effects[ENEMY_DEAD] = true;
|
||||
kill_it.set_precond(ENEMY_IN_RANGE, true);
|
||||
kill_it.set_precond(ENEMY_DEAD, false);
|
||||
kill_it.set_effect(ENEMY_DEAD, true);
|
||||
|
||||
REQUIRE(!kill_it.can_effect(start));
|
||||
REQUIRE(kill_it.can_effect(after_move_state));
|
||||
|
@ -72,13 +73,13 @@ TEST_CASE("basic feature tests", "[goap]") {
|
|||
goal[ENEMY_DEAD] = true;
|
||||
|
||||
Action move_closer("move_closer", 10);
|
||||
move_closer.preconds[ENEMY_IN_RANGE] = false;
|
||||
move_closer.effects[ENEMY_IN_RANGE] = true;
|
||||
move_closer.set_precond(ENEMY_IN_RANGE, false);
|
||||
move_closer.set_effect(ENEMY_IN_RANGE, true);
|
||||
|
||||
Action kill_it("kill_it", 10);
|
||||
kill_it.preconds[ENEMY_IN_RANGE] = true;
|
||||
kill_it.preconds[ENEMY_DEAD] = false;
|
||||
kill_it.effects[ENEMY_DEAD] = true;
|
||||
kill_it.set_precond(ENEMY_IN_RANGE, true);
|
||||
kill_it.set_precond(ENEMY_DEAD, false);
|
||||
kill_it.set_effect(ENEMY_DEAD, true);
|
||||
|
||||
// order seems to matter which is wrong
|
||||
actions.push_back(kill_it);
|
||||
|
@ -112,28 +113,28 @@ TEST_CASE("wargame test from cppGOAP", "[goap]") {
|
|||
// Now establish all the possible actions for the action pool
|
||||
// In this example we're providing the AI some different FPS actions
|
||||
Action spiral("searchSpiral", 5);
|
||||
spiral.preconds[target_acquired] = false;
|
||||
spiral.preconds[target_lost] = true;
|
||||
spiral.effects[target_acquired] = true;
|
||||
spiral.set_precond(target_acquired, false);
|
||||
spiral.set_precond(target_lost, true);
|
||||
spiral.set_effect(target_acquired, true);
|
||||
actions.push_back(spiral);
|
||||
|
||||
Action serpentine("searchSerpentine", 5);
|
||||
serpentine.preconds[target_acquired] = false;
|
||||
serpentine.preconds[target_lost] = false;
|
||||
serpentine.effects[target_acquired] = true;
|
||||
serpentine.set_precond(target_acquired, false);
|
||||
serpentine.set_precond(target_lost, false);
|
||||
serpentine.set_effect(target_acquired, true);
|
||||
actions.push_back(serpentine);
|
||||
|
||||
Action intercept("interceptTarget", 5);
|
||||
intercept.preconds[target_acquired] = true;
|
||||
intercept.preconds[target_dead] = false;
|
||||
intercept.effects[target_in_warhead_range] = true;
|
||||
intercept.set_precond(target_acquired, true);
|
||||
intercept.set_precond(target_dead, false);
|
||||
intercept.set_effect(target_in_warhead_range, true);
|
||||
actions.push_back(intercept);
|
||||
|
||||
Action detonateNearTarget("detonateNearTarget", 5);
|
||||
detonateNearTarget.preconds[target_in_warhead_range] = true;
|
||||
detonateNearTarget.preconds[target_acquired] = true;
|
||||
detonateNearTarget.preconds[target_dead] = false;
|
||||
detonateNearTarget.effects[target_dead] = true;
|
||||
detonateNearTarget.set_precond(target_in_warhead_range, true);
|
||||
detonateNearTarget.set_precond(target_acquired, true);
|
||||
detonateNearTarget.set_precond(target_dead, false);
|
||||
detonateNearTarget.set_effect(target_dead, true);
|
||||
actions.push_back(detonateNearTarget);
|
||||
|
||||
// Here's the initial state...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue