Jump to content
  • entries
    13
  • comments
    80
  • views
    34,944

AI: A New Frontier


Road Kill Kenny

3,791 views

 Share

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.

 

blogentry-3220-0-21218800-1347543082_thumb.jpg

 

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.

 

blogentry-3220-0-10728100-1347543090_thumb.jpg

 

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.

 

blogentry-3220-0-96115700-1347543098_thumb.jpg

 

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.

 

blogentry-3220-0-33856000-1347543106_thumb.jpg

 

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).

 

Anyway.....

 

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.

  • Upvote 9
 Share

7 Comments


Recommended Comments

Very nice system, Ken! Should allow for some interesting and fun gameplay. :)

The turrets following speed seems a bit high, but your system makes adjusting parameters quite easy. Finetuning the game is at a later stage, right? ;-)

Well done, man! Looking forward to see more.

 

Cheers

Link to comment

Thanks Chris. Yeh I have done no balancing in the game whatsoever. There is no real point in doing it yet because there isn't much of a game to play. But as you said, with my data driven design approach, balance is a matter of changing a few numbers in a well organised spreadsheet instead of wading through code to find the values.

Link to comment

Wouldn't you want all of the objects to inherit the same type?

 

Then essentially you're applying the AI to the same type but the child class *could* utilize the AI differently.

Link to comment

Wouldn't you want all of the objects to inherit the same type?

 

Then essentially you're applying the AI to the same type but the child class *could* utilize the AI differently.

 

No... you've misunderstood somewhere.

 

Either way, it works pretty much exactly how I want it to work.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...