Autowalker is now using the GOAP AI system and works way better. Still quite a lot of jank in the code but that'll get removed over time. Next thing is being able to detect when its near an item/enemy and properly react.
This commit is contained in:
parent
ff81c78d13
commit
d15c9b12fd
9 changed files with 84 additions and 47 deletions
11
tests/ai.cpp
11
tests/ai.cpp
|
@ -7,7 +7,7 @@
|
|||
using namespace dbc;
|
||||
using namespace nlohmann;
|
||||
|
||||
TEST_CASE("worldstate works", "[ai]") {
|
||||
TEST_CASE("state and actions work", "[ai]") {
|
||||
enum StateNames {
|
||||
ENEMY_IN_RANGE,
|
||||
ENEMY_DEAD
|
||||
|
@ -36,7 +36,7 @@ TEST_CASE("worldstate works", "[ai]") {
|
|||
// start is clean but after move is dirty
|
||||
REQUIRE(move_closer.can_effect(start));
|
||||
REQUIRE(!move_closer.can_effect(after_move_state));
|
||||
REQUIRE(ai::distance_to_goal(start, after_move_state) == 1);
|
||||
REQUIRE(ai::distance_to_goal(start, after_move_state, move_closer) == 11);
|
||||
|
||||
ai::Action kill_it("kill_it", 10);
|
||||
kill_it.needs(ENEMY_IN_RANGE, true);
|
||||
|
@ -48,7 +48,10 @@ TEST_CASE("worldstate works", "[ai]") {
|
|||
|
||||
auto after_kill_state = kill_it.apply_effect(after_move_state);
|
||||
REQUIRE(!kill_it.can_effect(after_kill_state));
|
||||
REQUIRE(ai::distance_to_goal(after_move_state, after_kill_state) == 1);
|
||||
REQUIRE(ai::distance_to_goal(after_move_state, after_kill_state, kill_it) == 11);
|
||||
|
||||
kill_it.ignore(ENEMY_IN_RANGE);
|
||||
REQUIRE(kill_it.can_effect(after_move_state));
|
||||
|
||||
actions.push_back(kill_it);
|
||||
actions.push_back(move_closer);
|
||||
|
@ -117,7 +120,7 @@ TEST_CASE("ai as a module like sound/sprites", "[ai]") {
|
|||
|
||||
auto state = start;
|
||||
for(auto& action : a_plan.script) {
|
||||
fmt::println("ACTION: {}", action.$name);
|
||||
fmt::println("ACTION: {}", action.name);
|
||||
state = action.apply_effect(state);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue