Sign in to follow this  
CIJolly

Ideas for a Modular Enemy AI

Recommended Posts

I am working on a top down run and gun, and have finished the weapons. By making weapon modules which added things like submunitions, explosions, freezing, poison, etc, I was able to approach the situation in such a way as to make a wide variety of weapons using combinations of exisiting code. (Diablo style, really). I am interested in doing the same thing with AI. That way, I can make modules for gun wielding enemies, melee chargers, healers, kamakazi bombers, etc, and load them in a modular way such that I can make a large variety of enemies by mixing things around. Any advice on what the best way to go about this would be? I handled modular weapons by giving them indexes which, when a collision occured, went to a lookup table to see the special effects. I'm getting the feeling that doing this with AI will be somewhat more involved. At the moment I was thinking having logic along the following lines: Loop through list of modules, giving the current game state to the modules decision making functions. These will return an int based on how beneficial the module is at this time (Eg, a melee module would return 0 when the player was out of melee range, a heal myself module would return 70 if critically damaged). These values could be modified based on AI personality. (Eg, a fearless enemy will have their run-away value slashed). The modules will then be randomly decided between, with those returning highest after the decision making process being more likely to be picked. Carry out the modules commands in the update method, checking periodically to see if the module should break (Eg, if taking large amounts of damage, stop heal module and reevalute. On the reevaulation, run away would evalute highly and be the most likely to be picked and acted upon). Once module the module is completed, reevaulate situation. Does that sound like a sensible plan? Hopefully it will allow me to make interesting and varied enemies. Has anyone else tried something like this before and has a suggestion to make it go smoothly? I'm using C#, if it's important. Thanks for reading.

Share this post


Link to post
Share on other sites
Can only one module be active at a time? If so what you are suggesting sounds reasonable (evaluate a 'usefulness value' for each and pick the best).

Share this post


Link to post
Share on other sites
Go with a FEAR-style planner. You can then do exactly what you want by specifying what actions each class of enemies can use, and let the planner sort when and how to use them.

Share this post


Link to post
Share on other sites
Quote:
Original post by Steadtler
Go with a FEAR-style planner. You can then do exactly what you want by specifying what actions each class of enemies can use, and let the planner sort when and how to use them.


Yep. Have to agree with that for more reasons than simply the modularity of it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this