This does a 'fit_sort' whenever the state is changed. fit_sort effectively sorts the actions by distance+cost so that the cost is actually present unlike the original algorithm.

This commit is contained in:
Zed A. Shaw 2025-04-03 10:14:50 -04:00
parent c014e65c13
commit c1aba2d5c8
5 changed files with 30 additions and 27 deletions

View file

@ -205,7 +205,5 @@ TEST_CASE("Confirm EntityAI behaves as expected", "[ai]") {
enemy.set_state("in_combat", true);
enemy.set_state("health_good", false);
enemy.update();
auto& best = enemy.best_fit();
REQUIRE(best.name == "run_away");
REQUIRE(enemy.wants_to("run_away"));
}

View file

@ -19,8 +19,10 @@ TEST_CASE("cause scared rat won't run away bug", "[combat-fail]") {
ai::EntityAI rat("Enemy::actions", ai_start, ai_goal);
rat.set_state("tough_personality", false);
rat.set_state("health_good", false);
REQUIRE(!rat.active());
battle.add_enemy(rat_id, rat);
battle.plan();
REQUIRE(rat.active());
rat.dump();
REQUIRE(rat.wants_to("run_away"));
}