Advertisement

Enemies intelligence increased level by level

Started by April 17, 2015 10:08 AM
5 comments, last by masterviana 9 years, 8 months ago

Hi guys,

I working on my first to game 2D i'm complete new on this kind of projects, i first try to animate my enemies on game scene, right now i setup a basic example to animate my enemies i've one array with objects that represent my enemies characters and with two timers encapsulated only have a random number that define if enemy will impulsed up and if enemy will impulsed left or right.

My game is a 2D game with a scenario that have various platforms where user and enemies can collide, all characters are following gravity rules and for enemy or user getting up it need to get an impulse for going up or left or right.

My goal is progressively put enemies more clever each level, start in 1º level only flying for the scenario without any goa and l finish with enemies try to avoid the user when use are in advantageous position or try to attack when user are disadvantage position.

I asking this because i'm not have experience with A.I, i think i can do this with a lot of for's and if's lets say hard coding, however i would like to know more about some A.I algorithms or some techincs to do things like what i what to do.

Can you guide me on my initiation on this, link for the right articles explain to me some technics for doing this things

I'd try to avoid the ifs, and do it via properties or variables instead. For example, a dumb enemy may react slower, so only makes decisions or updates every 1000 ms, an intermediate enemy 500ms, and a smart enemy ever 100ms. A smarter enemy might also look farther ahead to avoid projectiles or whatever.

By doing it via variables, it's easy to tune, and you don't have any branching in the code.

Depending on your game, and the level of cleverness, you might still end up with some code differences.

Advertisement
Thanks for you're reply, good tip the reduction of reaction time of enemy, i think i can follow your idea of tuning things using some parameters.
Like for example i can define a paramater that look ahead on the scenario to the position of the and velocity of player and with that "bots" can try to avoid a colision with player, your look ahead and if user are on a disadvantage position enemy can change the mode to the attacker and try to hit the player.
This paramter is getting more accurate for each time the update interval is reduced.

I would suggest the stretegy pattern

Simply put, you have n ways to do the same thing. Each way is nicely expressed with a class. Classes share a common base abstract class (interface) and one can switch from one (ie: DumbEnemyStrategy) to another (FlyAndAvoidEnemyStrategy). So a monster will have an instance of these classes, and can also change it at runtime! They... learn!

thanks for your reply i can use this yes, however i on corona SDK and in LUA i can do a similar thing to use the type of pattern that you have show me. However my goal here is getting aware of specifics algorithms/techniques for animate enemies with some kind of intelligence that grow level by level. thanks

In addition to the strategy pattern that was suggested by Arka80, you could also have a look at the composition pattern. Wherein everytime your enemy goes up in level you add on a new select piece of functionality via a class.

So instead of completely switching strategies you would simply add a new ability to the enemy class.

This is just an example I've written: Composite Pattern

Hope this helps!

Game Development Tutorials - My new site that tries to teach LWJGL 3.0 and OpenGL to anyone willing to learn a little.

Advertisement

In addition to the strategy pattern that was suggested by Arka80, you could also have a look at the composition pattern. Wherein everytime your enemy goes up in level you add on a new select piece of functionality via a class.

So instead of completely switching strategies you would simply add a new ability to the enemy class.

This is just an example I've written: Composite Pattern

Hope this helps

Nice tip too, you give a lot of new ideas. thank very much for your help

This topic is closed to new replies.

Advertisement