Hi everyone! First of all, I apologize in advance for possible grammatical mistakes in the text.
My friend and I are planning to create a small game with gameplay similar to the first XCOM games. The gameplay of the games looks like this:
- The playing field is a squared tile grid, every tile of which can contain lanscape part, obstacle or unit.
- Player and AI both has a couple of units.
- The game is played in turn - first all of the player's units act, and then all the AI units.
- Each unit is given a limited resource per turn - time units.
- Each action takes a certain amount of time units.
In XCOM remakes, this system was simplified to "each unit has two actions per turn", however we do not like this approach, and we want to do it as it was in the original games
Now we are at the stage of analyzing the feasibility of the project, and I had a question related to the implementation of the AI architecture.
We set ourselves the following requirements for the AI:
- It must choose behavior depending on the goal and current situation in the game
- The decision making process should be as little "hand-authored" as possible
- It must create a "meaningful" plan to achieve the goal, and not choose one "best" action at a time in the hope that someday the goal will be achieved
- The turn of each unit must end gracefully, and must not be interrupted in the middle of action - the time units limit must be implemented.
As an example of the AI unit plan:
run up to a position where you can shoot at a predetermined target, and run back into cover. If there are no firing points (there are not enough time units to reach the place) - take a position from which it can be done later.
I've read quite a lot of articles on the topic of how AI is usually implemented in games. Several of the most commonly used architecture options are:
- FSM (Finite State Machines) and HFSM (Hierarchical State Machines)
- BT (Behavior Tree)
- Utility-based system
- GOAP (Goal-oriented Action Planning)
- HTN (Hierarchical Task Network)
I do not consider FSM, HFSM and BT, because judging by what I know, they are not capable of planning ahead.
Utility-based system, in theory, can be hierarchical, but I see issue in the movement of the unit:
I don't understand, what is considered an action in the Utility-based system, concrete full path to the destination, or just action "Move" without clarifications?
As there can be many different paths, consider each of them as a root for hierarchical plan is pure madness - it can lead only to combinatorial explosion.
But if instead, we only think of this as "Move" action without parametrization - how can we achieve time units condition satisfaction? Especially, if there is 2, 3, 5 actions in the plan?
Moreover, an even more interesting question arises - why "Move"? Same position has different utility values, if unit has different goals - for example, attack enemy or take cover.
It turns out that the calculation of the utility of the current action should depend on the the next, or even on the entire plan.
GOAP and HTN architectures seems better for this situation - as they are planners in their nature. But in fact, even hardcoded knowledge "how to solve specific problem" or "rich AI knowledge about how to do things" doesn't help a lot. I still don't understand where do I need to put time units considerations.
For example, if "method" in HTN is action "Move" without parametrization, or concrete path to destitation?
I guess this is some sort of planning or optimization problem, but I don't quite understand how it can be solved, because i don't understand where to put that time unit heuristic part, so that it will not blow up.
I think that I misunderstand some aspects of this architectures, or miss some crucial parts in it.