Search Unity

What makes "good" AI.

Discussion in 'Game Design' started by StarGamess, Jan 3, 2016.

  1. StarGamess

    StarGamess

    Joined:
    Jul 21, 2014
    Posts:
    179
    So what makes the AI "good" and I am talking about enemy moster AI here. I mean sure the AI should not just randomly stop or walk the completly wrong way. But what gets you sold on AI what dings do you expect a monster does when it attacks you or when its chasing you? What are key features you find importent when slaying your digital beasts?
     
  2. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    It really depends on the type of enemy, I'd expect it to behave in a way that is consistent with what it is. Humans should behave in a 'human' way based in the level of trainmen they would've had e.g. Civilians would be behaving like some sort of neighbourhood watch with guns, military will be acting in a disciplined, trained way etc. A monster that hunts by stealth should be stealthy & not just blindly run at the player etc etc.
     
    Philip-Rowlands likes this.
  3. Philip-Rowlands

    Philip-Rowlands

    Joined:
    May 13, 2013
    Posts:
    353
    One thing I noticed while playing Jagged Alliance 2 was that human enemies will occasionally panic and run back and forth when outnumbered, especially if they're lower-level grunts. Having them make mistakes like a human under pressure isn't "smart", but I'd prefer that to "human" enemies that are unbeatably intelligent.

    Gauging and responding to threats is another thing. Half Life 2's gunships are programmed to focus on the biggest threat to them - if you launch missiles at them, they will focus on the missiles instead of you. That can be exploited by directing the rocket to fly in circles around them, but on the harder difficulties (which I haven't tried yet), they apparently come in pairs.
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I mostly want them to react in believable ways to whatever's going on. I remember in Oblivion, I got myself to the point where I could attack while completely invisible. So I could go up to pretty much any random bad guy, and start toasting him with flames and frost bolts and anything else, and he'd stand there saying "who's there?" If I were suddenly being attacked with flames and frost and whatnot from something I couldn't see, I'd sure as heck do more than that... I'd either start swinging in random directions, or dropping AofE spells, or failing all that, run like mad. But these guys just stand there and take it until they're dead.

    This is really in the same category as NPCs/monsters who get stuck running into walls, or have some simple exploit you can exploit over and over again. Basically, I think it's not so important for AIs to be smart... they just shouldn't be stupid!
     
    Alverik, KWaldt, Kiwasi and 3 others like this.
  5. StarGamess

    StarGamess

    Joined:
    Jul 21, 2014
    Posts:
    179
    Thanks for the input guys! One last thing what do you guys thing AI should be like in a game like Left 4 death or CoD zombies. A game where the AI is after you?
     
  6. StarGamess

    StarGamess

    Joined:
    Jul 21, 2014
    Posts:
    179
    And what do expect that a friendly NPC is capable of. So lets say the villages in skyrim or the citizens in GTA. What do expect from them?
     
  7. Philip-Rowlands

    Philip-Rowlands

    Joined:
    May 13, 2013
    Posts:
    353
    For starters, I'd expect them to actually realise when they have a bucket placed over their head :D

    EDIT: I'd also expect them to not overreact if you so much as glance at a worthless item they own, but only react if you actually steal it.
     
    JoeStrout likes this.
  8. StarGamess

    StarGamess

    Joined:
    Jul 21, 2014
    Posts:
    179
    Haha lol, now as you say that my AI would completely brake if it had its head covered by lets say a bucket since all the raycasting is done from the heads points of view. ;p
     
  9. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    I was always taught, that good AI loses in a way that the player finds fun. There's a lot of subjective terms in that sentence, and much relies on the game in question, so it may not be as helpful as it could be...but, it's a good rule of thumb. Does your player have fun in their conflict with your AI? If so, it's probably good.
     
    GarBenjamin and Kiwasi like this.
  10. LMan

    LMan

    Joined:
    Jun 1, 2013
    Posts:
    493
    The key with AI is to use it in such a way that it appears much more intelligent than it really is. AI is probably the most "smoke and mirrors" thing about game development.

    The words to live by are: "AI is never meant to win- it's meant to be fun to defeat."

    For instance- check out this video of the introduction of the "assassin" enemy in Dark Souls. Dark souls enemy logic isn't smart- that isn't what makes the game challenging. What makes it challenging is the way it uses it's enemy types- giving them different weapons, putting them in different environment situations, mixing and matching enemy types. In the assassin situation, they just needed to set up that "jump from behind" moment once. It doesn't need to happen ever again in any other encounter in the whole game.

    Designing that moment just once tells you everything you need to know about that enemy and how it works and why you're going to be filled with apprehension every time you see one of those guys. So rather than take all the time and effort to code for the assassin AI to "try" to jump the character from behind in any and all situations, they only need to set up a narrow street, open a door on trigger, have a guy run out, spawn a guy behind and have him jump the player. It's simple, it's dramatic, it sets a tone, and it's fun!

    You mentioned Skyrim NPC's AI- sure it's stupid! But that's really to be expected. You could pour tons of time and effort into coding NPC's to account for things like head buckets and other shenanigans, OR you could make 3 new enemy types for dungeons- which one offers more bang for your buck?
     
  11. Philip-Rowlands

    Philip-Rowlands

    Joined:
    May 13, 2013
    Posts:
    353
    The "smoke and mirrors" part reminds me of a paper I once read on the AI of F.E.A.R. (it's here, if anyone's interested). A large part of what made the AI great in that game was just playing the right voice clip at the right time - there is no point in asking an ally "What's your status", if you saw them get blown into chunks of strawberry jam.
     
  12. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    The main job of the AI is to loose to the player gracefully. Players are egomaniacs. The game is all about convincing the player that they have won by being awesome.

    On one of my early game projects I forgot that. I coded a learning AI for a space shooter. I put it through thousands of simulated iterations. Except it wasn't fun. It created an AI that fled the player for most of the game. When it got cornered it would launch volleys that the player could not avoid.

    So keep that in mind. The AI only exists for the player. That means an enemy should be interesting to defeat. And an ally should not get in the way of the players strategy.
     
  13. Master-Frog

    Master-Frog

    Joined:
    Jun 22, 2015
    Posts:
    2,302
    When the AI does what you would expect it to do. It just needs to feel like it's thinking. You want to be able to anticipate what it's going to do next, although sometimes you might be surprised. It will take on a personality. You will find yourself saying, "C'mon you stupid little bastard... just take one more step forward, you know you want to..." when it's done right.
     
  14. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    For a long time I looked at AI in games and thought "why are the enemies always so incredibly simple/stupid/predictable?" because I looked at it like any half-way decent programmer could easily make the enemies more intelligent behaving. However, over the past year (mainly due to discussions on the subject here on the GD forum) I've changed my view of this at least to a degree.

    For games I think the value of AI is all for fun. And while that could be making the enemies behave more intelligently (in the hopes of providing more of a challenge) the AI could also be focused on simply making the game world more interesting. Enemies that behave in interesting ways. Whether it makes sense or not. Like they could have exaggerated reactions for example.

    Maybe when 3 enemies are facing the player and the player takes out two of them... leaving a single enemy armed only with a knife. Now we could focus on the AI here to really try to make this enemy effective at the player. Maybe he tries to lead the player near a pool of acid and hopes to charge and knock the player into it. Or maybe lures them under a rope holding a heavy crate in the air and throws his knife causing the crate to drop on the player.

    That would be one way and surely could be interesting. But it may be just as much fun if we simply make that last enemy look down at his knife look at the player scream like a little girl and take off running in a sort of cartoon fashion in the opposite direction.
     
  15. IO-Fox

    IO-Fox

    Joined:
    Jul 14, 2014
    Posts:
    86
    Check out @AngryAnt . He does talks on AI.



    and..

     
    Last edited: Jan 4, 2016
    StarGamess likes this.
  16. chrissanders

    chrissanders

    Joined:
    May 24, 2013
    Posts:
    106
    what about AI for a fighting game .
     
  17. IO-Fox

    IO-Fox

    Joined:
    Jul 14, 2014
    Posts:
    86
    Hmmm... what I posted was more suitable for Utility Theory. I believe AI for a fighting game may best benefit from a fuzzy logic design approach.
     
  18. StarGamess

    StarGamess

    Joined:
    Jul 21, 2014
    Posts:
    179
    Ohhh fighting games are hard to make good AI for.. Especially if you want them to actually win fight...
     
    chrissanders likes this.
  19. LMan

    LMan

    Joined:
    Jun 1, 2013
    Posts:
    493
    But you never want them to win- winning is never the point of AI, You want them to follow a specific strategy that sets them apart from the other combatants. One opponent is designed to pin the character into a corner where he cannot move, while another is designed to juggle the player in midair and deny him access to his ground moves. This makes each fight unique, and requires the player to modify his strategy enough to beat the strategy of the AI. If he does, he wins, if not, he loses- the victory of the AI is the byproduct, not the purpose.
     
    Kiwasi, frosted and AndrewGrayGames like this.
  20. StarGamess

    StarGamess

    Joined:
    Jul 21, 2014
    Posts:
    179
    If they never win the game is too easy.. So it wont be fun unless your target audience it younger then 14or so. But lets take a game like age of empires the AI has to win a few times before you should be able to win or else the game wont be fun because you can beat everyrhing to easely.
     
  21. LMan

    LMan

    Joined:
    Jun 1, 2013
    Posts:
    493
    Maybe I didn't do a good job of explaining what I mean by AI is never supposed to win. Let me try to present it a different way.

    "Good AI" is not necessarily AI that is difficult to beat, nor is it AI that always makes the best decision. It is AI that makes decisions that are consistent with a particular strategy or personality.

    You could code a perfect AI- one that learns player strategies, and employs logic to find the perfect counter to that strategy within the game. AI that pathfinds perfectly in an environment, recognizes cover dynamically, interacts with other AI agents to work as a group... ad infinitum. What you're doing there is coding a "human replacement." AI that is supposed to mimic playing against an actual human being that wants to win. This is expensive, and could take years of work, and may not provide the user experience you want. For instance, in a fighting game, each AI character would behave the same way, and ultimately lack personality- a character would always attempt to fight in a way that countered the player's strategy regardless of who the character is and what their moveset is designed for. Because winning is the AI's ultimate goal, it ends up being a less ideal experience for the player with a vastly higher development cost.

    Rather than code a human replacement, you want to focus only on what enhances the player experience- so the AI is meant to be interesting, rather than actually good at the game. As a side product, the AI may win at the game, but the AI doesn't care about that, because it's focusing on presenting the player with a set of interesting problems. In a strategy game, A turtle AI will build lots of walls and defensive turrets, while steadily expanding. This will continually reduce the resources available to the player, but the AI doesn't need to care about that, it's just building and expanding and maybe raiding every fifteen minutes. A Rushing AI will build large numbers of low level units and raid every five minutes- this might prevent the player from establishing a stable economy, but the AI doesn't know that, nor does it care- it's just doing it's thing until it can't, or it happens to win.
     
  22. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    "Players are egomaniacs. The game is about convincing the player that they have won by being awesome" is one of the most succinct core principals of game design that I've ever seen.
     
  23. chrissanders

    chrissanders

    Joined:
    May 24, 2013
    Posts:
    106
    I can imagine, I'm working on an indie fighting game and we just began thinking about the AI>
     
  24. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    A good starting point would be to think of AI as player-experience-managing systems and -entities rather than opponents.

    If player experience is not your top priority then you're writing a simulator and a whole different set of rules apply.

    Of the two talks linked, the 2011 one is a better fit for the topic. The 2014 is on technique and implementation, which is irrelevant to this title.
     
  25. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,572
    The main thing you'll want to care about is level navigation and not getting stuck in walls or other npcs. This is overlooked in many games.
    Basically, you should be able to throw 500 monsters at one side of narrow corridor and tell them ALL to move to another side of corridor to the same target location, and they should do it without walking on the spot even for a second, and at the target spot they should form nice crowd.
    Enemies should not be omniscient and should sense position instead of knowing where player is.

    That's the primary.
    Actual behavior decisions are trivial in comparison.

    Keep in mind, that "AI" in game is not really "Artificial Intelligence", but "Artificial Life". The goal of "Artificial Life" is to be entertaining. The goal of AI is to do the task perfectly.

    Example of "AI" that is good but not fun is "Mortal Kombat Walker". Those are hard to beat, but not much fun to play against.
     
    JoeStrout, GarBenjamin and Martin_H like this.
  26. Dennis_eA

    Dennis_eA

    Joined:
    Jan 17, 2011
    Posts:
    380
  27. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I'd say what I appreciate in enemy AI is: 1) consistency, 2) complexity, and 3) personality. And probably in that order.

    In terms of difficulty, it's best if the player can adjust the level of difficulty, making the enemies easier or more difficult to defeat according to player preference.
     
  28. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,025
    I think it's often forgotten to focus on the illusion of intelligence rather than intelligence itself. True artificial intelligence can be boring to watch and very difficult or impossible to beat, which makes for pretty much the opposite of an engaging player experience. AI, just like everything else in game development, almost never suffers from being exaggeratedly explicit in its messages to the player. Even if you tell yourself that you'd like to see games becoming more realistic, the reality is probably more disappointing. Compare your average FPS to a head-cam paintball video on youtube and I think you'll get what I mean.

    So I think that the main thing is for your character to have a distinct identity driven by exaggerated stereotypical behaviour for that identity. You want to have the player look at the character and immediately categorize them and compare them to their own perceived identity in the game (seeing themselves favourably). Teammates should be very 'beta', villains always angry, mentors always wise and kind, non-combatants always scared, etc. You aren't trying to teach the player lessons in equality and seeing everyone through the same lens.

    Also something a bit less central but which I think is very important is to develop relationships between npcs. Npc relationships with the player are necessarily pretty one-sided and it can be hard to give them character but when you see them interacting with other npcs it really reinforces their identity.

    Perhaps even more important than character is reactivity, you want to have the player feel as if for a little bit of effort they elicit a clear and strong reaction from the character. This reaction I believe should be able to be reproduced dependably (i.e. the character isn't programmed to respond randomly). In the same way that the player wants to see the enemy stumble like a wounded bull when shot in the leg, they want to have every interaction elicit a clear and strong reaction (which is designed to make them feel better about themselves). Exaggeration here is not a bad idea, as long as it is consistent the player will not feel that it is fake.

    Here's an article on Halo's AI which I think is pretty informative, and another one by the AI programmer himself which is a bit more for technical stuff but nevertheless informative.
     
    Last edited: Jan 19, 2016