Update 388Made the vulture able to snap after prey, and carry it. Also lifted the utility comparison engine from living in the lizard only to being general, and applied it in the vulture.
The current AI layout is as such:
At the very top, there's the ArtificialIntelligence class, which has basically nothing going on in it except an empty list of modules. A specific creature AI inherits from ArtificialIntelligence, such as LizardAI : ArtificialIntelligence.
The first thing such a creature specific AI does is to start firing up a bunch of modules. In the case of the lizard, no less than these:
Vulture will likely have the same set, maybe except from Threat Tracker as it's pretty much an alpha predator and I don't know if it would even need to bother to look over its shoulder.
What's new since last time is that now the Utility Tracker lives as a module alongside the other modules. The Utility Tracker keeps references to the other modules it's been told to keep an eye on, and every frame it asks them for their Utility.
Utility is a value between 0 and 1, which is the AI module reporting back how urgent it is to do the thing that that AI module is responsible of. If the threat tracker returns a 1, get to cover! If the rain tracker returns a 0.7, time to start heading home. Prey tracker returning 0.9, there's some juicy prey close by and you should seriously consider the hunting behavior.
Utility Tracker keeps track of these, and do some smoothing and tweening on the values as well, to keep stuff more organic. It also applies a conservative bias (ie whatever is currently being done should get a little bonus, to keep the creature from flickering between behaviors) and similar neat things.
Every frame, the main AI script can simply ask the Utility Tracker for which module is reporting most urgency this frame, and then act accordingly.
Not all AI modules are hooked up to the Utility Tracker - for example the Path Finder is never really urgently calling for some decision, it's more of a means to an end.
This system is now up and running in both the lizard and the vulture, and seems to be working in both places. The vulture only has Path Finder, Utility Tracker and Prey Tracker at the moment, meaning that it'll spend each frame comparing the utility of doing nothing to the utility of hunting a prey, if it has seen one. So yeah, still some stuff that's gotta happen there. But basically not anything the lizard isn't already doing, so I don't expect it to be too troublesome.
Hunting behavior (except from the flying outside the room / between rooms part) is pretty much down already though, as it's basically all happening in the interaction between path finder, prey tracker and the actual body's locomotion engine stuff. I've already run around with the vulture and several lizards, and seen it pick its prey, hunt for a bit, change its mind to something closer, etc.
The actual snapping looks like this right now:
It's a little lameish, but when I went all out with body motion and neck extension etc the range became too big, and it was just impossible. Maybe it doesn't need a super power attack, but this little peck can do quite well... At least for now.
Also, since actually making it able to catch you I've started tweaking speed etc to make the challenge reasonable. It's difficult to tell, because it's a
very big difference in what's "reasonable challenge" when you're just testing in a room and can restart every 11 seconds, and when you've invested 6 minutes since the last save point in single player and really, really, really want to stay alive.
This is also the biggest liability with this enemy I think - because it's so big, and a climbing enemy, its speed becomes a bit unreliable. Whether or not it can find suitable grips when climbing makes the entire difference between it traversing the screen in three mighty strides and snatching you up before you know what hit you, and it fumbling for a good climbing route for 15 seconds while you take your time to leave. There's of course work that can be done to even that out - most notably having it switch to flight when climbing is not a good option, but also by clamping the max speed a little, etc.
Apart from the AI implementation, which I think is gonna pick up big time tomorrow when the modules go in one after the other, there's the big issue of flight. James and I had a talk about some of the design issues that needed addressing today, and now I just have to go do the technical implementations. Haha. Path finding, here I come!