Hacker News new | past | comments | ask | show | jobs | submit login
The Total Beginner's Guide to Game AI (gamedev.net)
477 points by stesch on Aug 14, 2018 | hide | past | favorite | 57 comments



I worked as an AI engineer on a few Playstation titles, by far the most important part of AI is messaging whats happening to the player. Usually a well scripted animation or voice cue will beat and cleverly written reasoning engine.

We always had loads of cool ideas, like enemies running out of ammo and throwing clips to each other. But the reality is, the player will never see it.

Uncharted does a great job of messaging the AI's intent to the player. The AI itself is fairly decent, but the messaging of intent is excellent.


As a counterpoint, I found the AI of enemy creatures in Rain World to be particularly satisfying, exactly because it didn't bother trying to explain itself to the player, so you basically had to watch enemies for a while and interact with them (and die a few times) in order to try and learn how their AI worked, rather than learning specific repeating patterns like patrolling etc.

This could also make for a very frustrating experience for some players because it took time to grok the intentions and behaviours of enemies. For example, I remember a review of Rain World (on Rock Paper Shotgun) where the reviewer raged because every time he died the game respawned the enemeis at random locations, so that they were not where he had found them previously and he had to learn their new locations all over again. In truth, the game didn't "respawn" anything -the game world kept running while the player was dead, as it did when the player character was absent, much like in, say, Don't Starve and other games that take a simulation-y approach to a game world. But, to the reviewer, this somewhat complex behaviour (certainly for a game that looks like a platformer) was very unexpected and very frustrating.


This was a lesson I learned while working on my own game which was a Dwarf Fortress type game (lot of interwoven systems, a lot of complexity). The biggest problem was while I had all these systems sometimes I, the developer who wrote all of it, had no freaking idea why something would occur. As with everything I've learned from a career in software engineering, complexity is always bottlenecked by UX and UI. Without good design and feedback for a user, complexity is either obfuscated to the point of being perceived as worthless or to the point of actually being worthless.


What's the game? I'm looking for new DF-like games to play. (Sorry if there's a way to DM that I am unaware of).


It's called Ripple but it's basically tabled for the time being at this point. I've re-prioritized long term goals in my life and I'm more in career-mode than independent-projects mode. If you're interested in it anyway you can check out the blog here: http://ripplega.me/. Little bit of technical and a little bit of design.

If you're in the mood for one you're probably already aware of my favorite which is Rimworld. If not, hurray for you that will be a fun time sink. Other than that, I haven't been following anything other than Stonehearth, which depending on who you ask was a failure but recently did come out as a 1.0.

Of course none of them could possibly approach the complexity of DF but the spirit has definitely spurred on some cool projects.


My biggest complaint about Rimworld, and in fact most games, is the lack of causality in random events. This is caused by developers giving up on this complexity in favor of just rolling dice. Just because it's hard to provide a UI that can express these things doesn't make for a satisfying experience by completely ditching the sense that events have causes. When an event has a cause, it gives the player a feeling of agency, and when it's just a roll of the dice that you can make go away by reloading the save file from a few seconds before, they're no longer disasters, but just random bullshit the game throws at you for the sake of making things hard. It feels cheap and lame.

If you get raided, you should be able to scout the caravan before it arrives. If bugs tunnel under your base, your ground penetrating scanner should detect them in time to get in position to defend. The list goes on, and the solutions to the UX challenges are there, if developers didn't simply throw their hands up and say "Welp, that's just too much UX for me!"

The game that got randomness right was Diplomacy. There's no dice rolling at all, but the randomness is there because you don't know what 6 other people are going to do when you put in your orders, but you rely on them holding to their agreements for the success of your own moves. It's a very satisfying mechanic because randomness is still causal. Randomness truly represents your lack of information, and can be mitigated by your ability to extract reliable information from the other players. When you get screwed by randomness, it doesn't feel like arbitrary bullshit. Knowing that effects have causes is crucial for people's ability to form a narrative about their experience.

What isn't necessary is to simulate reality down to the smallest detail, which is what I feel like most people try to do when they end up complaining that it's too complex to present to the user and has minimal effect on gameplay. One needs to be smart about simulating the things that do have an effect on gameplay by focussing on narrative mechanics, and not just trying to recreate physics.

In short, the solution to complexity is not getting rid of it and replacing it with unsatisfying random chance, but instead to create a renormalized model that eliminates the extraneous degrees of freedom.


This is a great comment. I totally agree the mistake that developers often make is to go too granular in the simulation instead of abstracting out these mechanics in a "narrative" fashion like you suggest.

I do wonder, as someone who made this mistake themselves to a degree, how much of this is because it is fun as a developer to work on these over-complicated simulations :)


Thanks! I will check it out. I tried Rimworld but after playing it for 20+ hours I began to see the patterns and non-randomness of the game (I have been heavily biased by DF). Plus everything the other in response. Im gonna check out your blog when I get the chance (currently on vacation).

I have just (just!) started making a DF like game but will be based off the D&D world. I am starting from the bottom because I want the challenge and have less priority on completing the game (and more on learning/challenging myself). When I mean bottom, I have almost finished creating a path finding algorithm that should be much faster than the current ones out there (geared towards 3D grids like DF). I also created a line of site algorithm that is symmetrical and (so far in testing) angle/corner perfect. World generation will be based on tectonic plate movement (bare bones version created).


That sounds very cool! Honestly I harbor no ill will towards my past-self who decided to sink 3 years into a game that will likely never see the light of day because I chose to work on hard (for me) problems like path-finding and map generation. I wrote the entire engine from the ground up outside of using Pixi.js for rendering sprites and learned a metric shit ton in the process. Bravo to you for diving in deep. I'm sure you'll learn a ton.

I realize more and more these types of projects are the ones that differentiate "good" developers from truly "great" developers.


Yeah its kind of funny that AI that plays smart and doesnt announce intentions to the player can be viewed as bad, dumb, or unfair, but when the AI enemies basicslly tell the player exactly what they are doing it is viewed as intelligent.


Well, on the contrary, I loved the AI in Halo 2/3, and half the time you'd be alerted to new developments by the AI on your side (Marines saying "aw f$%$ here comes $unit!").


An intelligent ai may not be fun to play with. An "ai" that signals to the player its intentions means the player can adjust and learn (and learning is the fun in a game).


http://allenchou.net/2016/05/a-brain-dump-of-what-i-worked-o...

Related article I've read from a naughtydog AI developer on uncharted 4


> We always had loads of cool ideas, like enemies running out of ammo and throwing clips to each other. But the reality is, the player will never see it.

Sounds like a problem with the particular constraints of the PvE genres you were working in, rather than with games generally.

Imagine an RTS where the player has to work their way up from grunt to strategist, and thus "plays every role" along the way. In that case, the enemy AI is the ally AI; the player experiences the allied side of it, and can use that to understand the enemy side of it, and thus make plans.


I don't think this is an issue with the game type, just a limit on what they could afford to do. Messaging this to the player could be accomplished w/ a voice line & animation, but that costs money or disk space (remember, Playstation game).

This same problem would exist in a RTS, since the player still needs to know that the random ammo appearing is from squadmates passing it off. Otherwise, the player would be just as confused, possibly thinking they were picking up ammo off the ground.

Like most things in life, this is a tradeoff between cost to implement VS value.


Just posted this in another thread, but it’s especially relevant here:

I work at a small AI startup, and our CEO worked on the AI for the NPCs in F.E.A.R. [0]. He has written about developing the goal-oriented action planning [1] approach in the game (and is linked to in this article). Great to see how it was done!

[0]: https://en.wikipedia.org/wiki/F.E.A.R. [1]: http://alumni.media.mit.edu/~jorkin/gdc2006_orkin_jeff_fear....


STRIPS was the original algorithm Monolith used for fear. The interesting thing about STRIPS is that it uses A* pathfinding to solve a decision-making graph.

More info: http://aigamedev.com/open/review/planning-in-games/


Errata URL for reference [1] - Overview of Games using GOAP and related technical papers:

http://alumni.media.mit.edu/~jorkin/goap.html


Sorry I'm a moron today - correction for my own OCD:

I said "Errata" - I meant "Addenda"


Yes, that's the original GOAP paper. I still remember the demo where the agents work in tandem alternately tossing grenades and ducking and covering in seemingly intelligent tandem ;)

Curious about the AI startup you are working on now?


Definitely! The company is Giant Otter Technologies [0], and I usually explain it as building bots and learning insights from existing conversations. I work as a front end engineer on the bot platform and tools.

[0] https://www.giantotter.com/


What startup up is this and are there roles in nyc?

I would like to know more . Jpg


At the end of the day, FEAR felt very much short of the expectations, just like the "smart gunships in Half Life that learned to shoot down incoming RPGs on their own" and the supposedly goal driven AI in STALKER which was never really implemented.


I didn't have any expectations, but FEAR AI was one of the best I've seen in games. I could replay the same battle over an over again, and the enemies did different, convincingly intelligent things, based on my own actions.


To be fair, the AI in STALKER (A-Life) was dialled down significantly prior to release as although it performed great, it made for a poor narrative experience as you could never really ensure it wouldn't break the game continuity in some way.

There are mods out there now that allow you to enable the full A-Life simulation and honestly it is very impressive even to this day.


>smart gunships in Half Life that learned to shoot down RPGs on their own

I want to know more about this.

was it just preprogrammed ability/method that was unlocked after a time or was there some sort of machine learning?


I suspect that the gunship was simply programmed to shoot the closest hostile entity, which happened to be the player's rockets. This kind of emergent behavior is actually quite common in gameplay programming. In any case, machine learning was not involved in the development of Half-Life.


I remember playing FEAR for the first time a few years ago and being totaly disapointed so much that I asked Steam a refund. I think it's mostly because I've been playing CoD in the years before and it was too different and I couldn't make the switch to a different FPS style.


I used to teach game AI. Most of the articles I read are badly researched, incomplete, and full of opinions of the author based on whatever they noticed trying things randomly in their game.

This article, on the other hand, is comprehensive and very well-written. Anyone interested in this topic should give it a read.


This might be because games are a young medium, but I find a lot of “primers” on game design to feel like subjective reflections of the author’s ludography. The sort of fundamentals a level designer for a 90s first-person shooter would give seem very different from a 2010’s indie platformer dev or a big-budget JRPG producer. There doesn’t seem to be a lot of insight that’s indifferent to genre or team size yet.


Nice intro! Some of the more advanced techniques (MCTS, GOAP/planning and so on) get the short shrift, but it's totally expectable for an intro article.

And the early section on constraints is especially great. Game AI has to worry about enjoyable performance and variety of challenges given almost no CPU time, which makes all the difference...


Very cool. I would love it if there was a computer game where you basically created different AIs for different scenarios that you played out.



The soundtrack is also excellent, I have it in my instrumental playlist for when I'm working. The only problem is that sometimes it's too good and I want to pay more attention to it than the work.

https://nervoustestpilot.co.uk/album/frozen-synapse-original...


I played Frozen Synapse ages ago and didn't link what I was doing in any way with trying out an AI. Maybe the game has changed in recent years. or maybe I'm overestimating game AI.


Early access, but gladiabots[0] may be up your alley. Giving intents to robots using a visual programming language, then testing them against another team (human or AI). Ive been enjoying it anyway, decent balance of puzzle game that isn't too complex as to seem like a job.

[0] https://store.steampowered.com/app/871930/Gladiabots/


There is this top down space rts game which does just that. Browser based, had electron port. I can't for the life of me remember it's name. The AI construction was very limited/simplistic though, still a good deal of fun.


Obligatory mention of Screeps: https://screeps.com/


Yeah, I bookmarked this to see if it would help with my code!


Good intro. There is a lot of history covered here. And of course, the art is in the implementation ;)

Currently, an interesting new (neuro-)evolution is happening in Game AI. With the OpenAI 5 and it's "180 years of training per day". We begin to see the feedback loop of game design being influenced by AI.

Detroit: Become Human is one recent example of how AI is used to manage the enormous complexity in game narrative. And some hotly anticipated titles for the fall including Last of Us 2 and Death Stranding will demonstrate the state-of-the-art.

And I don't think it's just for open world environments. Or a new generation of cloud-enabled VR / AR experiences. AI will also be used to re-design "flaws" in arcade classics. And render them infinitely playable into the future.


>Detroit: Become Human is one recent example of how AI is used to manage the enormous complexity in game narrative.

What does it do? From walkthroughs I've seen, it looks extremely scripted.


If there's anything that Detroit: Become Human does well, it's branching narrative. Does it approach true freedom? Not at all. But compared to, say, Telltale games or something like Until Dawn, it's pretty impressively open ended[0].

Now, do I recommend it? Absolutely not. It starts off really good, especially if you're already expecting another Heavy Rain or Beyond Two Souls. But after a few hours (maybe just one?) it gets heavier and heavier handed. It's impressive how quickly it turns from an interesting story about both intolerance and what it means to be human, and just becomes a series of scenes that practically scream "DO YOU GET IT YET? DO YOU?".

Probably still the best David Cage game I've seen, mostly for the strong intro and branching narrative, but that's like picking your favorite Uwe Boll movie. If you want to play one of these style of games and can handle horror, I'd point you toward Until Dawn instead, as I think that's probably the best example of the genre.

[0]: [Spoilers] Here's a graph of the choices available in one mission. Some are significantly more linear, some are even more complex. Note that other missions may include two or more (Up to 5 I think?) starting points. https://d1lss44hh2trtw.cloudfront.net/assets/editorial/2018/...


Do you have any links on the Detroit AI you mention? All I see on the GDC vault are talks about lighting and engine tech, can't seem to find any game AI info.


Do you have links to any information on the use of AI in Detroit's narrative? Searching for "Detroit AI narrative" isn't working well for obvious reasons!


Detroit engine is 100% proprietary. Hopefully, Quantic Dreams and David Cage will share more in time. But there are still several generations of DLC to be released ;)


I thought HALO had good AI, and there was a writeup somewhere (IDK where) by Bungie devs about how they implemented complex seeming behaviour with some relatively simple/dumb rules.


Within the context of a game it [generally] doesn't need to be a full blown AI solution.

Combining route finding, goals & priorities, situational awareness, and also adding in some flakiness so it's not perfect can give a really good and usable approximation to AI from the human players perspective.

The computer player needs to have rules and knowledge in place about the game such as how to get around the maps and how to shoot / evade the enemy all without being too good.



I think so, I haven't read through it but it looks like the one, thanks for finding it!


I dunno about dumb, the morale break functionality was pretty brilliant.


Dumb was really a poor choice of words, I basically wanted to say that the rules were incredibly simple and even so you get this complex behavior that comes out of it.

I remember the first time I played HALO and the guys talked to each other, and it wasn't just random sound effects they actually did the thing they were talking about. If the Elite guy said to "flank him" they would try to flank you or whatever, it was very cool.


my favorite game of all time is Activision's Battlezone. everything was near perfection, just wish to see a better AI


Is it possible to use machine learning to have the AI improve itself?


Apart from potential performance issues I can't think of any other reason why not. Keep in mind however that games are made to be fun and sometimes ability to predict actions of not-so-smart AI opponent might be better that facing unpredictable and too intelligent AI.


That's pretty much how OpenAI for DotA 2 is being developed.

It's learnt the game from scratch by self play and can best professional players in some game modes.


Yes! This is the domain of Reinforcement Learning: https://en.wikipedia.org/wiki/Reinforcement_learning


I was thinking you could have an AI character play the level and that would reinforce that character's moveset.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: