Search Unity

Simple Methods for Achieving "Fun" Interactive Enemy Behavior

Discussion in 'Game Design' started by GarBenjamin, Nov 10, 2014.

  1. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    I'm starting a new thread for AI just because there is a difference in views between some of us. Out of respect for the others it makes sense to create two threads. The other thread is focused on conceptual principles, understanding machine learning, it's latest implementations and research and so forth. Hmm... I just noticed the other thread is locked. So I guess this is all we have.

    This thread is focused on actionable solutions we can all use to make better "smarter" enemies and perhaps even better game managers. Basically we'll break down the problems to understand them and prepared with that information we will be able to design a solution for the problem. We may then revise the solution (remember this is all design level just using sentences to illustrate the "how to") to make it simpler.

    While I am not against people posting about machine learning I would prefer it be in a game specific context. Not talking about some academic research but rather focusing on how it was or can be applied to games to solve a specific issue.

    I don't have time right now but will post later tonight or tomorrow.

    But please contribute if you wish.

    I think a great place to start would be to discuss the AI issues we have all seen in games. Give specific examples of the undesired behavior. And we will try to figure out the solutions together.

    It's possible such a discussion may not belong here since designing the solution will center around implementation. Personally I see it as directly related to game development because smarter opponents are certainly a key element of game design. But in the interest of not wanting to be a hypocrite if a mod feels this doesn't belong here feel free to cast if out to Gossip or wherever. ;)
     
    Last edited: Nov 10, 2014
    Akasharkxx likes this.
  2. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    To start things off here are some examples of bad AI documented on YouTube.

    Psychic Soldiers
    Enemies who can automatically determine your exact "hidden" location far away within a second of sniping one of their comrades:



    I Just Wanna Run

    Enemies who know where you are but choose to take the longest path to reach you... when in fact they never needed to reach you (assuming they have guns):

    Actually this one is just plain wrong on many levels. Notice the moment the player moves into the other room the enemy somehow magically knows the player has moved even though he is down the hall looking the opposite way. Another Psychic Soldier!


    Your Kung Fu Is Stronger Than Mine
    Enemies who cannot recognize simple spamming patterns:

    This makes me kinda want to yell at the video JUMP GIRL JUMP AND ATTACK!


    We'll give this problem identification phase a bit of time for people to post their own examples of "bad AI". Say until tomorrow night (~ 24 hours from now). Then we can get to work dissecting exactly what went wrong, when and where.

    After we have ripped them down we can then get to work designing solutions.

    Sound good? Hello... is anyone out there? ;)

    So... please feel free to post your own examples of "bad AI". Can be something very simple or something that looks like it would be pretty difficult to fix.
     
    Last edited: Nov 11, 2014
    RJ-MacReady likes this.
  3. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    One thing that frustrates me is when I see a.i. that completely cheats, but it's trying to be passed off as just being really intelligent or really well designed.

    Take Starcraft 2 for example, the VS mode artificial intelligence is not actually any smarter than the very hard level artificial intelligence. It just gets more resources by default, and this isn't explained clearly I actually found it out online when I was googling why cant i beat the insane computer.

    In fighting games, it always pissed me off how they managed to block every single attack. Of course later on I figured out that they actually have access to the hardware level input device, so they literally know when your about to punch before any visual telegraphing even can occur. Contrast this with the human player who is human who takes several hundred milliseconds to respond.

    Both of these are examples of inadequate artificial intelligence that is covered up with game breaking, unfair advantages that are never actually revealed to the player. Instead it's just called harder artificial intelligence or a harder difficulty setting.
     
    carking1996, Ryiah and GarBenjamin like this.
  4. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Excellent stuff! We can already see a pattern that makes for poor AI: CHEATING.

    In the first video Psychic Soldiers, the enemies instantly knew exactly where the player was located. In the second video I Just Wanna Run, the enemy instantly knew when the player had crossed the low barrier separating the rooms even though he was down the hall with his back facing the player. This means 80% of our bad AI examples so far employ cheating to give them advantages dealing with the player. I don't mean just a little cheating here and there. I think a bit is understandable at times but we are talking about cases where clearly the primary strategy is based on cheating.
     
    Last edited: Nov 11, 2014
    RJ-MacReady likes this.
  5. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    And there are AI's that are overpowered and omniscient, and AI's that are dumb as rocks. In either case, no effort is made to simulate the correct behavior a person would take. I wouldn't doubt these AI's all use complex pathfinding algorithms, logic trees, etc. But nobody sat back at any point and said. "What is the desired end result? What is this supposed to be like when it's done?"
     
    GarBenjamin likes this.
  6. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    I agree and have thought the same thing. In my own projects there are times I have taken a break of a couple weeks then went back and play tested before resuming work and noticed something I missed. I have got into a habit of where I now approach it by taking on the role of each enemy. Basically writing down what is my strategy for doing my job whether it is tracking down the player, guarding a treasure, being a "citizen" of an area (meaning I don't care about the player and have nothing I am doing but hanging around living but if the player enters my turf I am gonna get him). That helps a lot for me anyway.

    The first step in achieving anything has to be determining what the desired end result is. In this case, what are the enemy behaviors we want to achieve? You have to be able to define these things before you can focus on a solution.
     
    Last edited: Nov 11, 2014
  7. slay_mithos

    slay_mithos

    Joined:
    Nov 5, 2014
    Posts:
    130
    Cheating AIs can be seen in various games, but it's definitely in 3D semi-stealth games that it shows the most.

    There are many examples of cheating AIs, or at least AIs that rely on some informations that should in theory not be available to them (making them act even weirder sometimes).

    The Elder scrolls games are somewhat famous for their AI that can chase you down and pinpoint your location, in a manner where you can never hide unless you kill the pursuers or completely exit the zone. A bit less present in the last one, but you can still notice it if you know where to look (the enemies seem to instantly notice where the attack came from, and gradually forget about it over a few seconds).

    Various 2D combat games read the inputs, to somewhat counter your moves, making counters much more valuable than any aggressive ways, kind of defeating the purpose of having a lot of moves, combos or powers, when you only really hit with fast attacks during the enemy attack animation/recovery.

    A few RTS games also have the opportunity to give the AI various bonuses over you, for making things harder, some of which are down to cheating (revealing the map, among others). An AI is usually much more capable than an average player to utilise such informations, because it can keep track of everything and still keep up with all the productions and timings, nearly as well as a very good (pro?) player could.

    In most cases, when it's forced onto you, those cheating AIs tend to make things much more gamey, and less realistic, often making the game less fun to play as a result.

    In itself, cheating AI is not bad, it's just a way to give your AI all the informations it needs to perform what it is supposed to do.
    It is also a very cheap way of doing so, resource wise, because it means all the information is stored in a central place, where every entity can access it, meaning that way less checks need to be done for each entity.


    What really matters is "how" you make each entity use such information, and maybe how you couple it with basic information it still gathers about the world around itself.

    Having access to everything doesn't mean using it, per say, meaning that even if your AI has the specific location of the player, it doesn't need to act like it is aware of it.
     
    entropicjoey1 and GarBenjamin like this.
  8. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    That reminds me, SC2 Insane computer also can detect if you build near its base ramp or either of its fast expand locations, in spite of being concealed by fog of war.

    Omniscience actually seems less intelligent, now that I think about it. An enemy in a stealth game that I sneak behind who never notices me, that feels more intelligent.
     
    GarBenjamin likes this.
  9. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    What about replicating expert play? In simulations, we often use subject matter experts (SME) to model what expert-play looks like. Then, we simulate how they do it via code instead of building an all-knowing, super-crazy-intelligent-AI. It might not even make that many adjustments based on the player's actions. It's just one of 2, 5, 10 different AI's that you've coded up, and then you throw in a few random variables for difficulty and replayability, such that players have to work at it to truly grok it. I suppose you could further advance this by genetically evolving it, as players interact with it. Not necessarily easy and yet, probably more than adequate for most games.

    Gigi
     
  10. slay_mithos

    slay_mithos

    Joined:
    Nov 5, 2014
    Posts:
    130
    It also depends on a lot of other points, like your time and budget, or the minimum specs you want, for titles that are not just for a hobby.

    At the end of the day, when you make a game for a hobby, it's alright to go all out in whatever way you want, because it's your own free time, and it's not worse than playing other games, if you like it.
    But when you are out to at least pay back what the game costs (usually, you want at least a bit of profits), you have limits on a lot of things, and a very complex AI might take a lot away from making the rest of the game, or up the costs significantly.

    I tend to often forget about this aspect when I write, because it has never been my situation when it comes to games, but it's something we have to keep in mind too.
     
  11. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    I hadn't considered giving them ai different "personalities" based on real people's play styles. That's a whole new avenue.
     
    Gigiwoo likes this.
  12. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Here are a few more examples of bad A.I. documented on YouTube...


    Nobody Could Have Seen That Tiny Hole In The Ground!
    Enemies who are just plain dumb. As in unaware of obvious hazards in their immediate environment.


    Are They Critters Or Are They Spikes and Leaves?

    This one kind of pains me to cover because these retro games are some of my favorites.
    And this game is very well made overall as far as levels and core play mechanics are concerned.
    However, it succeeds despite having some of the lamest enemies ever.
    When you watch the video pay attention to the enemies. The game play would be the same whether the player was facing this specific enemy, practically any other enemy in the game, or even if attacking a spiked block or leaf fluttering in the wind.
    In fact, the enemies remind me of most of the new games I see coming out on Mobile. They seem to have no idea the player is even near them. No desire to attack. No desire to escape. Basically, they are just rolling along day dreaming until they are killed.
     
    SteveKouts likes this.
  13. RockoDyne

    RockoDyne

    Joined:
    Apr 10, 2014
    Posts:
    2,234
    Or they behaved like most NES enemies. Most of the them in shovel knight are handled more like level props than complicated entities.
     
    LiberLogic969 likes this.
  14. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    I always liked enemies when they just go back and forth... One of the most challenging enemies is one that just won't stop moving real fast back and forth.

    And jumping randomly. And throwing hammers constantly.
     
    Last edited: Nov 12, 2014
    Deleted User, GarBenjamin and Gigiwoo like this.
  15. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    I was thinking about that while watching the video. Reflecting on NES and Genesis games I played. It's strange the enemies were almost always very simple. Moving forward off screen. Moving left and right in a certain area. Moving in a wave pattern across the screen. In fact, it seems like most of the enemies just moved in patterns with no reaction to the player at all. Yet they were often some of the most challenging enemies due to positioning and timing. Certainly they were usually fun to deal with. Shovel Knight looks like a lot of fun to me. It looks like an actual game.
     
  16. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    What makes them so hard is that they don't react to you. So you must react to them. This puts you in a constant "aah!"... "oh crap!" Kind of state of mind. I played asteroids on an original machine on saturday and it's amazing how much perfectly predictable physics can present a formidable challenge.
     
    Gigiwoo, carking1996 and GarBenjamin like this.
  17. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Kind of all goes back to we should be focusing on fun not on simulating reality. Which means actually we shouldn't focus on AI as a means to make things more realistic in most games.

    In fact, looking at the 2nd video of the enemy soldier who is running around from corridor to corridor I would say the video author is having more fun from being able to make the enemy run like that then he would get from the enemy running down the corridor, jumping over the small barrier while shooting the entire time. He is clearly involved in play. Finally, at the end when he reacts to the enemy as just an enemy he fires a few rounds and now is in a barren area.

    Of course, there needs to be enough challenge so the game is not boring. But just maybe AI in games should be focused on finding ways for the player to play.
     
    RJ-MacReady and Gigiwoo like this.
  18. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    Yep. And the worst AI you can make is what I would call the "Perfect Killer". This is AI that heads straight for the player, attacking constantly without pausing, or getting distracted or anything. It's the most realistic and yet game ruining. The AI is supposed to play into the player's fantasy, dropping like flies if they're Master Chef or giving you a heart attack if it's Amnesia. That's why it's there. Sometimes that means it has the sentience of a fruit fly. And that's great.
     
    entropicjoey1 and GarBenjamin like this.
  19. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    ^ Such win! Very Design.
    Gigi
     
  20. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    The Onion: Guard In Video Game Under Strict Orders To Repeatedly Pace Same Stretch Of Hallway
    This has been said before, but an AI doesn't need to be smart. It simply needs to never appear dumb. (For example, letting you rob the shop because you've put a bucket on its head.) But not appearing dumb is the hard part, eh?
     
    GarBenjamin and RJ-MacReady like this.
  21. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    We've had this kind of discussion before regarding "play" in the big thread about game design. Interestingly, I have always viewed AI from perspective of making enemies behave smarter to be better more interesting opponents. Not solely from a what AI aspects would make this enemy more fun to mess around with? In that regard, making them imperfect is best. Perhaps even tripping over rocks.
     
  22. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    Enemies can be just there for a moving target, or they can be mere obstacles. Can be. Or... they can be a walking trampoline (Goomba) or transform into a kickball (Turtles in mario). I never look at enemies from the logical perspective of what they are, how they would think... I think of them as something to toy with. Like an armored enemy that patrols. But he happens to be under a beehive... I start imagining all the ways to defeat him with the environment. And so forth.
     
    entropicjoey1 and GarBenjamin like this.
  23. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    Or maybe he won't go under the beehive unless there's a reason for him to leave his patrol pattern... getting spotted isn't an option, so I have to drop a $5.00 on the ground.
     
    GarBenjamin likes this.
  24. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    TLDR:Learn to slow down and read. ;)

    I agree with that. I have always viewed that as interaction which to me is the essence of games. The more (and interesting) ways the player can interact with the game the better. The interaction does rely on AI though. However, when most people talk about AI it is in the context of making enemies smarter including the other discussion about making them actually learn.

    This all probably explains why I view AI as a simple matter of information gathering and reactive behaviors. It always seemed straightforward. I think this is because without really taking the time to discuss it specifically or even put some deep thought into it.... I knew AI in a game world is a different beast than AI in the academic sense. I knew the focus on realism was out of place in games (in most cases) and instead the focus should be on play. But never really made the logical connection of the two formally.

    Good game AI does not focus on making enemies appear super intelligent. Good game AI focuses on supporting the interactions with enemies (and environment) to provide more fun. A better experience. While this may often require enemies to act more intelligent... ultimately it all comes back to their interactive (reactive) behaviors which may end up appearing not so smart. Can they be baited and lured to another position? Can you influence them to jump to their death or to simply make them do something funny?

    I am kind of thinking out loud here just bouncing ideas off you guys and gals so that is the explanation for my rambling. ;) Bottom line is if an enemy seems "dumb" that may support a play experience much better than the enemy appearing "smart".

    It is interesting to see all of the articles talking about dumb enemies in games and saying games should be past that. And wondering why developers are so lazy they make enemies do stupid things. It seems in some regards they missed the mark by not recognizing the fun and play value in dealing with dumb enemies and certainly dealing with enemies you can manipulate. That is definitely fun. I have often tried luring enemies to each other (of different types) hoping they would fight but they don't. Now that is a case where AI could be used. Again nothing fancy needed. I firmly believe game AI can always be simple. We don't need more advanced AI we just need more AI.
     
    Last edited: Nov 14, 2014
    Teila likes this.
  25. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    So... looking at the example of "bad" AI in the first video: Psychic Soldiers.

    I do consider this a case of bad... actually nonexistent AI.

    What could change to improve this scenario?

    I think the comrades could look around, examine their fallen comrade for a couple seconds. Obviously, they can tell the direction the bullet came from so looking over to that general direction makes sense. Perhaps firing a few random rounds. All of which would likely miss. Then splitting into three groups with one staying behind, one heading to left and one to right in an attempt to circle around the sides and box in the player.

    That would have seemed much more realistic, been fair to the player and put some added pressure on the player.

    Any thoughts?
     
  26. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    While it doesn't have so much to do with behavior per se, one thing I liked in Dragon Warrior I, was that enemies you encountered had a slight variance to their stats. For instance, a Slime could have 3-5 HP, 2-4 Attack, 1-2 Agility, etc. Thus, each enemy felt like an individual. (Note: the rewards were not random. Killing a tough slime awards the same rewards as an 'easy' slime, 1XP and 2G.)
     
  27. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    What is the AI or interactive aspect of this?

    EDIT: I am not knocking your post. I just mean how do these stats impact the interaction between the player and these enemies? What is the difference between the enemies having these stats and not having these stats? What is the difference between the enemies having different combinations of these stats?
     
    Last edited: Nov 13, 2014
  28. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    I would simplify. They can handle an enemy in range of sight. Anything else is too fubar, so by default people will take cover. Since there's no way of knowing where the sniper(s) are they'd go for the nearest armored vehicle/structure. Then, there'd be an armored patrol or drone patrol visible vantage points where the shot could have come from. They'd never stop looking if there was a sniper out there.

    +They would bust out heat vision, so there's no way you're not going to be spotted by the patrol, so you have to gtfo.
     
    GarBenjamin likes this.
  29. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    That's a solid response too. Taking cover. Searching for sniper if they are supposed to be aggressive. Not sure if they have access to drones and such that is why I thought about sending out a couple troops to scout the area.
     
  30. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Of course, if those enemies were predators the player would (or should) expect them to be able to determine exactly where the bullet came from. But in the context of this game with silly humans their behavior does not match expectations.
     
  31. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    No, those are just people, not perfect hunters from another planet. That would be a whole other game.
     
  32. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I think there's a logical pitfall to watch out for. We observe, "Lots of well-designed games (e.g. Super Mario Bros) have essentially no AI," from which we can safely conclude "Advanced AI isn't needed for some game designs."

    But we can't conclude "No game design requires (or would benefit from) advanced AI." There may be lots of game designs — including ones that haven't been invented yet — that would be great fun to play, and rely entirely on advanced AI. Certainly the designers of Creatures and Black & White would say so (though I don't think either of those is the pinnacle of what they were attempting to do).

    Or put another way, let's not confuse cause and effect: quite likely games like Mario are designed they way they are BECAUSE they couldn't do any advanced AI... it's not that they didn't do advanced AI because of the design they wanted to do.

    So, yeah, if you're doing something like a platformer you can think of enemies as simply mobile obstacles, and it makes no difference whether they are given faces or are merely roving campfires or whatever. But that ground is well-trodden... what new design paths could we explore if the enemy behavior were more complex?
     
    TonyLi and AndrewGrayGames like this.
  33. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    It just adds more variation to the enemies. In practice in the actual game, it doesn't wind up making a huge difference, because the variations are extremely small. Done properly, though, I could see how having variants of an enemy that are tuned differently - even if they use the same AI script - would force the player to re-evaluate their tactics and treat each enemy as an individual, thus leading to more compelling conflict/combat.
     
    GarBenjamin likes this.
  34. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    This is a good one. The "simple" approach to a fighter AI is to use a nondeterministic state machine. For any state the agent is in, we look at what the other player is doing and the distance between them, and then stay in the same state or pick a new one (possibly with some randomness thrown in).

    This can work, if it's done well. You can always add more states, or tweak the transitions among the existing states, to fix any behavioral problem you observe.

    But the thing is, this is hard, and players are very good at finding exploits like the spamming attack shown in the video. Once they do, your game is solved, and solvability is very bad for replayability.

    So fixing it by hand is certainly one option, but when you're dealing with a nontrivial number of states and variables, this is really hard and time-consuming. This is where I think a learning AI might help, in several ways:
    1. Used offline (i.e. during development), you could pit a learning AI in the player avatar against your state machine or other "real" AI in the enemies. Let it take days to fight over and over, and if there are any simple exploits to be found, there's a good chance this will find them. Then you can hand-fix your "real" AI before you ship.
    2. Or, again offline, you can train up an AI opponent and actually ship that. There are several ways to do this: either have it imitate a human player, or have it just develop its own play style to maximize some reward function. (But if you stop here, you risk shipping with exploits, just like a hand-crafted state machine.)
    3. Used online (during play), it ought to be possible to make an AI that recognizes when it's getting smacked in the same way repeatedly, and do something about it. This eliminates exploits, making the game much less solvable, and forces the player to keep changing their attack patterns, which may be fun.
     
    GarBenjamin likes this.
  35. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    I see what you mean. I didn't mean more complex AI is never needed or never a good thing. Mainly I was getting at the AI should focus on supporting interactions between the enemies and the player (or environment) to provide more fun. A better play experience. Instead of AI being focused simply on making enemies seem smarter period.

    However, I still have not seen a case where advanced AI is the answer. From what I have seen it is always a lack of consistent basic AI or simply a lack of implementing basic AI consistently.
     
    RJ-MacReady likes this.
  36. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    "However, I still have not seen a case where advanced AI is the answer."

    I found the same to be true extremely early on, when trying to emulate stealth in a Zelda game. Any real attempts to have the enemy solve navigation of the environment with observing it in real time didn't work. I created a system of way points around the map and had the enemy find the closest one to him that was closer to the player than he was. It failed, as well, due to my own limitations at the time. In the end, random movement with a charge attack would have been better anyway. I just got lost in the trees without seeing the forest.

    All of my more robust solutions to hard problems have been the least complex and most apparent. That type of solution is usually the correct solution.
     
  37. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    "This eliminates exploits, making the game much less solvable,"

    I don't think every game can be broken down and compared to a puzzle with a solution, though I may be missing something. I think if that were true, there would be nobody playing repeated deathmatches in fps games, for example or any enjoyment in tournament style battles in Starcraft. Instead, there's a definitive tend toward simple AI in games with more players, games that perform better, etc.

    I think a game that is about solving AI gets old faster than a game with simple AI that focuses on presenting the player with diverse challenges. Simple AI lends itself better to component based level design, as well. You can drop a goomba anywhere and it still presents the same challenge. A thinking stealth game AI must be in a perfectly setup environment.

    Or maybe I'm making this more complicated than it needs to be.

    The most popular toy in the world is a ball. It pales in comparison to the complexity of a remote control helicopter, but does that mean it is hit is necessarily better? And are balls really obsolete playthings?

    Something to think about
     
  38. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    For the fighting game spam issue if I was asked to resolve it I would approach like this (and I don't know specifics of their implementation I am just guessing based on observation).

    First, I would look at the information gathering methods available to the computer fighter henceforth known as Droid123.

    It appears that Droid123 may be unaware of being hit (at the AI level). Damage is applied so it should be aware but it might not be. It might simply be scoring a hit removing some "health" and updating the droid's health bar. If Droid123 is aware of being hit, it almost certainly is not aware of where it was hit. In this case lower body.

    So, that is the first thing I would look at. What kind of information gathering mechanisms are in place. This droid needs to know not only that the player just landed a hit on it but also the hit was to its lower body. For simplicity's sake I call this sort of thing a probing behavior or information gathering behavior. It can be called a feedback sensor or whatever.

    If it already has this kind of damage sensor built in and the information is already being collected then I don't need to do anything. In that case, Droid123 is just not making good use of the information it has. If Droid123 does not have this mechanism then I would add it.

    Now what I would do is in the Droid's "brain" have it make use of this information.

    Before attempting to attack it would first check and see "hey I was just hit" and "that hit was on my lower body".
    Now it can react based on this information. Maybe it can do a jumping attack which has the chance of dealing damage to the player while at the same time serving as a defense against another attack to the lower body. However, I'd know this would simply set up another spamming scenario. The player would kick low. Punch or jump kick high. So nothing is solved. What is needed is some unpredictability.

    So, the droid examines its options. It can continue on attacking as it normally would (follow its normal pattern and most likely getting spam kicked again), try to do a jumping attack, jump up and away from the player, try to move away or attempt to unleash a small flurry of attacks (go for a chain of 2 to 3 different attacks).

    If Droid123 had an equal chance of doing these 5 things it would most likely break the spamming behavior. Of course, the player may hit the droid high instead of low and in that case Droid123 would react according to this new information. Perhaps choosing to duck and attack, crouching and moving away, rolling backward, or staying where it is.

    That is just an off the top of my head description of how I would approach the issue. It may need refinement based on play testing. I may give it a short term memory (fancy way of saying I store the area last hit by the player) and only react as described above the second time the player has scored a hit on the same area. It depends on fun. There is some fun involved in being able to land a couple quick hits on an opponent in a fighting game. So maybe a couple are acceptable.
     
  39. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    If I were asked to solve a similar problem, I would use some rationalism to kick things off. Remove everything that is not absolutely true all of the time. Any conclusions I make and then build my AI on are going to have elements of doubt if I start with a bad foundation.

    So, in this game, what always is true?

    Maybe: ranged energy attacks always trump everything else? Maybe blocks are unbreakable? Are grabs able to thwart blocks? I can figure out the basic relationships between all the moves, and the concepts behind the moves, themselves and from there I will build an unbeatable AI.

    Once I have this god ai, I can divide him up into sub classes who share things in common with him. Eventually, through experimentation, I'll discover the patterns that make the AI so potent. I can then extrapolate those to other AI units who are too easy, or have weaknesses.

    Voila, no ai learning. Just good old fashioned using of the noodle to solve problems with simple machines (yes the ai is just a machine!)
     
    GarBenjamin likes this.
  40. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    That is the ideal way of doing it. Knowing exactly what the rules are. Are attacks possible which put the other fighter off balance? And so forth. We are basically saying the same thing. If you know the game and what kind of behaviors are possible and desired then through play testing and refinement you can use what many would consider very simple AI methods to solve the problems.

    But if someone showed me that video and asked for help on the spamming issue I would reply with what I wrote above. By simply adding a ReactToBeingHit state the droid would be much less vulnerable to being low kicked to death.

    In our own games it is even easier. We know the rules as you said and can really tune the behavior as we see fit.
     
    RJ-MacReady likes this.
  41. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    I didn't get to read the whole thread yet, I'm in bit of a rush atm, but here's how I'd solve those problems.

    1. Psychic Soldiers solution:

    - Check the comrades line of sight, if they were facing the target, they got info about the direction the shot came from. Give them a second to scan that direction at given distance, and if the player isn't visible based on some conditions, dispatch a search party in that direction, retreat back, or whatever else was intended. They might wanna take cover too before taking any planning actions. :)

    - You can further add conditions to the "getting hit direction info" like their intelligence level, or game difficulty. If you're playing on easy then maybe 20% noticed the direction of the enemy, then it takes a few seconds to convey that information to the rest before they search, and on higher difficulty 90% of them reach that info, and as a majority, issue follow commands to the rest, or something.

    - You can also further add random chance of the leaders (higher ranks) catching the info, then they can simply issue the orders to the rest to follow, and the search starts sooner instead of lower ranks trying to organize alone, or tell their leader.

    2. I Just Wanna Run solution:

    - Well that's pretty much just bad pathfinding. It didn't look like that solider had a gun so he couldn't shoot, but if he had he should have.

    - Crossing to the other room can be solved by placing triggers at those cross-sections so they AI knows he has to jump over. But its an old game, things like that were acceptable back then. :D

    3. Your Kung Fu Is Stronger Than Mine solution:

    - This is a tricky one(at least for me), but I would solve the spamming by giving the AI some short termed memory. Like two last hits received. Then if it gets hit twice by the same attack, it knows to change its approach.

    - But! That will only work if the player attacks with the same kick twice or more. What if he attacks with a kick and punch, then kick and punch, then kick and punch, etc? Then it wouldn't register as a spam attack. So what I'd do is actually make 3-4 different memory bars, and current attack bars. First one containing 2 attack memory slots, second 3, third 4, etc. And all of those would fill up and empty as the AI takes attacks (at the same time not one after another), and if one of those fills up, and matches with current attack bars, a pattern is recognized, and its time to change the approach.

    - I completely approve the AI reading user input to counter attacks in a game like that. Its pretty much the best way to simulate eyes. Furthermore you can delay their reaction time by your decided difficulty level, and your AI should have stats, to determine whether they can counter those attacks in the first place. Maybe its stronger defending the upper body but weaker defending the lower. And for every calculation I mentioned (and will mention), I like to throw in a bit of random chance. As humans have luck, good and bad, so should the AI. So throw in some randomness there. Maybe their short term memory fails and the bars empty, maybe they don't catch that attack when normally they would, maybe they luck out and hit a bit harder than usual, and so on.

    4. General Cheating solution:

    - To me the best way to avoid cheating is to try to simulate human behavior. Program it as if it was a human making decisions.

    5. Nobody Could Have Seen That Tiny Hole In The Ground! soluton:

    - As mentioned above, I'd just throw in some triggers to detect the edge, and stuff like that, or raycast with one ray in a scanning motion vector. :D

    6. Are They Critters Or Are They Spikes and Leaves? solution:

    - Not really a solution, 'cause I don't think there's anything wrong with it. As you guys have already concluded. If you ask me, games like that are made to be like that, and most our childhood games are like that, and this being retro, its just sticking to the roots. Plus not all those enemies are enemies, they're just dangerous to touch. :D
     
    GarBenjamin likes this.
  42. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    This:
     
    ChrisSch likes this.
  43. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Does anyone know if the AI in LOTR: Battle for Middle Earth II is cheating? I can't beat it at all one on one on "Brutal" difficulty. :D

    Its sending soldiers at me like crazy I can't comprehend where is it getting so much resources and soldiers at the same time to be able to produce that many that fast. I can either focus on building resource buildings and little to no army or both and have a bit of each but in any case it overwhelms me pretty much in the first 5 minutes. Or I just suck that bad. :D
     
  44. LiberLogic969

    LiberLogic969

    Joined:
    Jun 29, 2014
    Posts:
    138
    I think this could have a huge impact on the enemy AI. For example, a Slime that rolls higher offensive stats would enable a highly aggressive AI and a Slime that rolled defensive stats would become a meat shield for Slimes possibly by using a "defend" ability on allies with less HP/Defense. A Slime that rolled a high "Int" stat may gain the ability to heal and buff other slimes/enemies. This would in turn make every fight feel unique, and players would have to determine which enemy of the group is the highest threat and develop strategies to overcome each fight, even though they are all the same enemy. Now imagine if you threw in some other enemy types into those fights... things could get really interesting. The Enemy AI could have Stat requirements, like equipment and skills that the players may use. This could be checked all the time, so for example, if Enemy X has its strength increased to X by a friendly buff, they now enable AggressiveFighterAI and gain the "Slash" ability.
     
    Last edited: Nov 19, 2014