britown

Creative-Type Impersonator

🌸请别在工作死🌸


I sometimes like working on never-to-be-finished video game projects


Right now I'm making a game called Chronicles.


Wanna make a game? Here is a list of great C++ libraries to use.


I maintain a Letterboxd in much the way that I assume people maintain bonsai trees.


This is Owen:
Owen
And this is Molly:
Molly
Furthermore, this is Max:
Molly

I know I want to implement a fairly simple FSM graph for NPC AI but I'm running into a few issues with the implementation. You want to very simply say things such as "If you can reach the player to use a specific ability on them within X turns, try to do that."

You want to be able to define these rules-based behavior states in assets and not in code because that's how we're doing things.


Here are the constraints:

  1. Abilities are lists of actions that may request 0-N targets or perform 0-N actions on the target results. These are defined in assets and are completely arbitrary. (You could have a single ability that uses dependent multi-stage targeting that heals, pushes, or damages completely arbitrary sets of actors)
  2. Determining the "Result" of an ability is thus done by executing the actions onto a copy of the game state to simulate it.
  3. Because of these two things it's very hard to reference a specific target request or specific action from within an ability because the it's generally taken as whole.
  4. If I wanted part of the behavior graph to say something like "move into range to use the blink arrow ability on an enemy" that sounds simple but blink arrow actually takes two different targets, the second being the teleport position adjacent to the first target, thus how does the behavior script know what "Use on an enemy" means??

There is a concept of result cache which is data collected during the virtual execution of the ability for drawing UI, so hypothetically you could build a graph of potential movement squares with all the different decisions in a given ability and then dyjsktra's it searching for a path that satisfies a declared set of end-goals "target enemy is damaged" or "target enemy is closer to you than they started"

The issue with this is that hypothetically you would be copying the entire game state in every node of a giant combinatorial explosive behavior graph, which will probably go nuclear and die for performance. But maybe it's worth trying to see!


You must log in to comment.

in reply to @britown's post:

you're absolutely right! It's something I've been thinking about a lot and it's why there's now a "results cache" that happens from the simulation because ti was getting crazy to keep resimulating for immediate-mode rendering. There might be some happy medium between full game-state deep copies and smaller-form snapshot data, and honestly that might just be an optimization detail in the end??

Kind of feeling like the play here is to jsut do the big bad dumb system and see how slow it is and go from there because I'll learn a lot about the constraints from that!