AI is something that I haven't really touched, hence the 'new frontier' title. However, overtime time learning how to program games and learning about useful techniques such as finite state machines, it did not worry me very much and I had a good idea of how I wanted it to work.
There are three major things that I wanted when conceptually designing my AI system and they were:
- Diversity of AI
- Data Driven AI
- Modular AI
Observe the below diagram. Simple enough. It depicts a turret class which is also a finite state machine and has a number of states in it, namely Idle, Attack and Seek.
Now this all seems fine and dandy (if I may say simple as well). However, if we want to have a different type of fixed unit such as a cannon turret then we have a problem because we have to re-code all of the states of behavior even if it generally behaves the same. The image below shows how this can get out of hand.
Now consider the below image. you can see I have taken away the behaviors from the fixed unit classes and placed them externally so that they not owned by the fixed unit. Now anything can re-use those behaviors.
For the most part this is obvious, however, what if we want to have the same types of object utilize and chop and change different behaviors. We get what is shown below. This was ultimately my goal when creating this AI System.
It may seem a little crazy and you might thing "WTF is going on there", but keep in mind that out of the 3 goals I had for the AI system, simplicity wasn't one of them. I just wanted to have as many options as possible. This way I can make the most out of every type of enemy or NPC in the game. There is nothing worse than only being able to use something in one single way for an entire game.
The below video demonstrates this working in game, shows a bit of the Data Driven side of it and also some code. Enjoy.
From a game design perspective, this kind of system is very good as you make the most out of each npc type and mechanic. The player see's a turret and from prior experience in the game that they first came across it they know what it does, it kills them..... However, with little effort the turret can be changed to be smarter and behave differently. The player will have to use what they know about a turret in order to figure out how to tackle the turret behaving differently... and this can be done with any number of npc's not just turrets, effectively diversifying the entire game.
For example, you may start the game with the turrets not looking around, then as the player progresses you introduce turrets that look around, then ones that revolve.... Then when they think they have the turrets down pat, you introduce a room full of turrets that behave differently . This effectively keeps everything fresh even though you are using the same thing. (note this is just one example, it is important to have more than just one enemy type otherwise it could get a little bland).
It may have been a bit much to follow perhaps because of its complexity / abstract way of doing it.... but more likely because I suck at explaining things. However, I hope you at least got the gist and learned something perhaps. I know I have.