Jump to content

Kiting enemies or "How not to do AI"


Recommended Posts

Maybe it's just me, but I feel like there should still be kite-able enemies. For example, poorly trained/organized warriors, simple beasts, those who have fallen into a beserker rage, and anything or anyone else that would be likely to blindly charge a target when aggravated should all be kite-able. for the sake of argument, let's call these low-intelligence mobs . They should exist, and you should be able to cheese them simply because they not designed to be smart. However, mid and intelligence-level mobs, should pose a different problem, use different tactics, and be smarter. basically they should run off a different AI script. And perhaps, low-intelligence mobs could use higher level tactics when they have a leader/captain with them to direct them. In my opinion, it's another way to add variety to encounters.

  • Like 1
Link to comment
Share on other sites

Then again, when mongols pulled the western knights away from the infantry and then just retreated ahead all the while peppering the knights with arrows, the knights probably felt it's all very unfair, unsportsmanlike and gamey. Especially when the mongols would then much later when the knights were dead tired, turn around and make them completely dead.

 

Then proceeding to kill the infantry as well. Also very unfairly as the infantry had few ranged weapons and no way to reach the horsemen.

Annoying strategies, but usable on occasion. If the enemy is slower and has no ranged weapons, there's no reason to not use the easy way out.

 

If an arrow from a distance pulls the worgs in first and the slower orcs follow behind, should be workable to first deal with one group and the rest later.

As long as not everybody goes the exact same speed and the enemies are not blind to their friends getting hit 4 feet away, it should all work out.

 

And most intelligent enemies should have some kind of ranged capability. If only a couple of darts.... or ..rocks picked from the ground? Would that be possible.

This is not the kind of thing we're afraid of in terms of kiting and pulling. We're talking about the kind of AI behavior you see in some RPGs and especially in MMORPGs.

 

If we applied this MMO pull logic to your example, the Western knights and infantry would all be standing within 50 yards of each other. The Mongol would carefully edge closer - in full sight of the enemy - until he got to the exact distance were the two knights standing 25 feet away noticed him but the five infantry standing ten feet away from the knights. The knights charge screaming while the mongol backs up another 50 feet. The infantry is completely unaware for no apparent reason.

 

The mongols would then kite the knights by running in a circle around them peppering them with arrows. The infantry stares at them. The knights chase the mongols around in a circle rather than standing their ground, retreating to the infantry, trying to cut the mongols off on a turn, nope... just chase them haplessly. Eventually the knights die.

 

The mongols then walk the 100 feet back over to the infantry and begin shooting the infantry. The infantry yells in surprise and attacks. Most of them are mowed down by the mongols fire and the survivors are cut to pieces by the mongol swords.

 

This is the sort of situation we want to avoid. The AI shouldn't be butt stupid. The areas should be designed in such a way that there is a manageable amount of enemies to create a challenge without being overwhelming, and the enemies can't be trivialized with combat tactics that take advantage of a level of combat ineptitude you wouldn't see on a peewee hockey team. :) There's nothing wrong with concept of pulling and kiting in terms of how they might actually work against an intelligent enemy.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Also wanted to talk about certain status changes affecting AI. Fire, Acid, etc and enemies reacting to status changes effectively. Trying to put out the fires of their allies, etc.

My blog is where I'm keeping a record of all of my suggestions and bug mentions.

http://hormalakh.blogspot.com/  UPDATED 9/26/2014

My DXdiag:

http://hormalakh.blogspot.com/2014/08/beta-begins-v257.html

Link to comment
Share on other sites

It would definitely be great if all enemies didn't behave in essentially the same manner. For example, a pack of wolves that's out hunting and notices you is probably going to try to attack you. Especially if you piss the wolves off. Although, you'd be surprised how much basic strategy wolves can use... But, that's beside the point. As opposed to this aggressive take, I think if you were attacking a bandit camp, and you kill a scout on the wall with an arrow, ALL The bandits suddenly rushing out of the camp straight at you, is pretty silly. Why would they do that? They have a perfectly defensible position, and they don't even know how many foes are out in the woods, or where they are. All they know is that at least ONE foe has a bow, and he's within range of their wall. Maybe they're more alert now. Maybe they send a small group of now-alert bandits to carefully make their way out a side entrance and attempt to stealthily locate you. Maybe they all take some cover from the direction the arrow seems to have stricken the man on the wall (maybe one of them has to go inspect him, first, a la "He was facing this way, and it's in his chest, therefore it came from this general direction.)

 

Along the lines of that example, it would also be awesome if they took more than 3 milliseconds to alert each other to your presence and whereabouts. I hate it when enemies have hiveminds. Some guy sees you for a split second before you knife him in the lung, and he NEVER calls out or otherwise conveys any information to anyone else, and yet, since you didn't knife him in the back, everyone totally knows where you are now.

 

But, I digress. That's getting into a stealth mechanic. But, it is pertinent to AI behavior. I think if you make the sets of behavior scripts varied and complex enough, you can simulate pretty awesome AI without having to program an actual sentient computer that eventually becomes Skynet. 8)

 

So, kiting an enraged troll? Sure. Of course, a simple way to fix that "He keeps turning around to attack the last person who attacked him" problem is to have a switch in place (let's call it "ChangeTargetWhenHit"). So, whenever he acquires a target, turn that switch off. Then, when he successfully executes at least one attack on his current target, flip the switch back on. Voila. The next attack that strikes him will cause him to change targets again.

 

Not very elegant, but my point was only how simple it would be to break up the "I can kite everything always!" problem.

 

 

Lets give you two enemies (A and B) attacking three characters (C, D, and E). You could have AC & BD & E, BC & AD & E, C & BD & AE, AC & D & BE, ..., it's a combinatrics problem. Which means that the number of possiblities just for attacking scales upwards at an extremely rapid pace as number of combatants increase, for just a simple attack. That doesn't even try to put any logic into it like assessing what the best combinantion is, or to try and assess the right time to use a special ability, or any other logic. If you give each enemy a bow and a sword, double the possiblities. Give them a special ability too and you'll triple the possibilities, and that's still without even trying to determine which is the most appropriate. It's not inconceivable to end up with AI potentially having hundreds of combinations it has to evaluate in less than a second, with each of those combinations introducing even more variables that have to be evaluated (Like if it has an AOE special ability and must then evaluate the position of all of it's allies and their likely future positions).

 

The main problem with what you're suggesting is that the game doesn't have to go through the entire list of available actions every second. It first decides whether or not to attack, then, ALL options that don't coincide with its decision are ruled out. It doesn't go "Should I use a healing potion? No... Should I use a healing spell? No... Should I run away? No.. Should I enter into an idle animation? No... Should I block? No..." etc.

 

When a player character gets attacked, what do you do? You do some math on your own. "How much damage did that do? How quickly can it be repeated? More quickly than I can kill something before fleeing, or win the entire battle? Yes? Okay, then I should probably stop taking damage." Then, you act accordingly. You don't just start thinking of all the possible things you could possibly do. At that point, there are only so many ways in which you can escape damage. Get out of enemy range, use some kind of damage-blocking ability, heal yourself, etc. So then, you check to see if you have healing potions, or sufficient mana, etc., for a heal to be useful. Again, you get to determine the priority order for checking these things ahead of time. So, when you get to a viable option, you take it, and the rest are moot.

 

And I'm pretty sure a computer can react a little faster than a human brain when it comes to evaluating factors and executing actions.

Edited by Lephys

Should we not start with some Ipelagos, or at least some Greater Ipelagos, before tackling a named Arch Ipelago? 6_u

Link to comment
Share on other sites

  • 3 weeks later...

I'm replying to endorse this post, pulling one enemy from a group of multiple enemies, even when one of those enemies is a challenge for my party, almost always feels out of place and gamey. Inexperienced players, or players who just aren't looking for that kind of challenge in a game will probably end up pulling, whether subconsciously or not, and if you ask if they enjoy having pulling in the game they will almost certainly say that they do, as that's how they've learned to play the game and it is how they continue to play and enjoy the game. I personally cannot pull one or two enemies into a large group of heroes to get wailed on without have post-traumatic WOW flash-backs =p. Perhaps pulling could be an option you could choose in order to keep both gruops happy, although that would contribute to option bloat.

 

Alternatively you could have the ability to pacify large groups to allow pulling single enemies as a kind of spell or psionicist ability. Allowing fragile groups of casters, rogues, and rangers to be able to take large groups of enemies as proficiently as groups of warriors and paladins who can take more damage. Not that I'm aware of how the game's balance will pan out in the end, mind you.

  • Like 1
Link to comment
Share on other sites

I just wanted to say that there should be no performance limitations when writing AI. I wrote my own AI for a tactical RTS game that is an MMO so it is designed for hundreds of games to be played on one computer at the same time. I haven't finished the AI yet, but I have lots of ideas for making it feel human with some really simple decision making... because most of the time we act on our gut and don't evaluate all the possibilities.

 

Pathfinding is an issue, but it can be avoided by using various tricks.

 

Pulling is very easy to avoid by having monsters call for help, I would be surprised if this wasn't added to the game. The main issue that allowed pulling was a limited LOS in baldur's gate for example. If you only revealed one kobold in the mines, you could attack and kill him, and the kobold behind him wouldn't see you until you advanced further. In addition, sometimes monsters get caught in a choke point and line up, allowing you to take them one at a time or to kill them with a lightning bolt. Level design is very important to fix this.

 

Kiting is only avoidable if you balance the movement speeds carefully and design the levels so you can't fire upon melee enemies who can't reach you. I think this is more of a design issue than an AI issue, though you want to avoid flip flopping.

  • Like 2
Link to comment
Share on other sites

I just wanted to say that there should be no performance limitations when writing AI. I wrote my own AI for a tactical RTS game that is an MMO so it is designed for hundreds of games to be played on one computer at the same time. I haven't finished the AI yet, but I have lots of ideas for making it feel human with some really simple decision making... because most of the time we act on our gut and don't evaluate all the possibilities.

 

I'd be interested in any problems you've seen (other than the ones mentioned) with enemy AI that you've tried to tackle. You don't have to give code, but I think everyone would appreciate better enemy AI. One of the things that I think isn't generally discussed is what the actual "problems" are: what questions is the computer not answering when making a decision that a human player would innately do? If we can come up with some of these, the actual AI implementation can become easier.

My blog is where I'm keeping a record of all of my suggestions and bug mentions.

http://hormalakh.blogspot.com/  UPDATED 9/26/2014

My DXdiag:

http://hormalakh.blogspot.com/2014/08/beta-begins-v257.html

Link to comment
Share on other sites

I think a big problem in a non-grid based game is how you define the movement space. Do you have thousands of little pathfinding nodes, which seems like what the infinity engine used? There are tricks you can use to put simple pathfinding queues into the terrain to help the AI decided where and how to move.

 

Pathfinding is the biggest issue in terms of performance, I have heard some estimates of it using 50% of the CPU utilization. Thats why I made a really simple movement system that generally goes in a straight line but can navigate around walls pretty well. It still needs a little bit of work, but you really don't need to check every possible option.

 

A human wouldn't stand and look down 2 paths and decide which one is shorter before running to attack someone. A human would just pick one, probably favoring the right side, or the side that has the least obstacles so they could run without tripping or something like that.

 

This is an opportunity to make it smarter with simple tricks. Make the monster look for other monsters. If there is some combat going on, the monster should either go help, maybe because its blood thirsty or maybe because it is curious. A smarter monster might go the other way to flank from the side, or run back to get reinforcements. It is much faster to only pathfind for one monster and have the other monsters use his results. This is especially true if there is a leader in the party.

 

So basically, if you focus on how humans make decisions (a psychology degree helps here) then you can find lots of shortcuts to make your AI make human like decisions faster. The problem is if you are trying to make an inhumanly perfect AI that can match up against a player who can freeze time to think. That is impossible and should not be the end goal (the devs are smart enough not to go down this path of course).

 

If you don't use the pause feature, the human should be at a disadvantage. One of the only reasons why my AI is beatable is because the game is slow paced. Originally we tested it at 5x the current speed and none of us could win, even though it has some major flaws (due to being incomplete). I guess one reason is that Kiting is a core feature of our game and our AI can do it very well. Also, you can't pause the game to think, so that is an issue.

 

The way I set everything up is very ad-hoc. I just use weights for all the AI decisions. I made up arbitrary numbers and tweaked them a little bit.

 

A standard melee attack is worth points equal to the damage it does. If it is AOE, add to it the range of the attack, perhaps using a multiplier.

 

So you do 1-8 damage, your threat value might be 8 for that, +20 for your hit points = 28.

 

If you have 10 hit points, but can cast fireball for 3d6 x 16 spaces, then your threat value might be 44 or 172 depending on addition or multiplication.

 

You don't have to do any math if you don't want to. You could just give the monsters AI tags like "hates wizards" or "bully: targets enemies who are small stature", "bloodthirsty: targets closest enemy but switches to nearby enemies that are wounded". This is something that should be done anyways. Fighting a group of ogres and fighting a group of goblins should feel totally different in terms of enemy tactics. In most games the player behaves differently based on what monster it is, but monsters always behave the same. I would love in P:E for every monster to have their own behavior profile, as well as individual differences, such as this goblin is afraid of fire, and this goblin likes to flank.

 

The nice thing about personalities is that they make the game more fun and realistic, but also are much easier to calculate then the best possible target to attack, either to kill the player efficiently or to make sure the battle isn't too hard. (You might want the AI to avoid twelve goblin archers from ganking the wizard in an ambush).

 

So by combining all these techniques together I think its possible to make powerful AI without having to break the bank on performance. It does require lots of careful thought and planning and lots of creativity.

Edited by ShadowTiger
  • Like 3
Link to comment
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
×
×
  • Create New...