Enemies and now using the GOAP AI to decide when to attack the player, but it's very rough right now. I need to sort out how to store the AI states and use them in the System.

This commit is contained in:
Zed A. Shaw 2025-03-14 11:14:25 -04:00
parent 77f2e94515
commit ad71631809
13 changed files with 61 additions and 30 deletions

View file

@ -46,9 +46,9 @@ namespace ai {
return (state | $positive_effects) & ~$negative_effects;
}
int distance_to_goal(State from, State to, Action& action) {
int distance_to_goal(State from, State to) {
auto result = from ^ to;
return result.count() + action.cost;
return result.count();
}
Script reconstruct_path(std::unordered_map<Action, Action>& came_from, Action& current) {
@ -65,11 +65,12 @@ namespace ai {
}
inline int h(State start, State goal, Action& action) {
return distance_to_goal(start, goal, action);
(void)action; // not sure if cost goes here or on d()
return distance_to_goal(start, goal);
}
inline int d(State start, State goal, Action& action) {
return distance_to_goal(start, goal, action);
return distance_to_goal(start, goal) + action.cost;
}
ActionState find_lowest(std::unordered_map<ActionState, int>& open_set) {