• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Game Mechanics Artificial Intelligence

Alice

Darts addict
Forum Staff
Moderator
It's a follow-up of sorts to the discussion on @Carnivius status update here. Generally, he mentioned that in some cases making "perfect AI" is easy and how to make it "stupid". I think the topic of artificial intelligence in general opens up quite an opportunity for discussion, hence this thread.

One thing I find interesting, is how to make artificial intelligence credible; as in, make it appear that the computer-controlled characters feel like more or less real people, with their imperfections (that is, if the characters are people in the first place). @NazGhuL suggested making some "random" failures or making delayed reactions, I added a bit of inaccuracy (which might work with shooters) in place of perfectly aiming for the player. I guess these sorts of imperfections would work in the action games.

Aside from imperfect capabilities there's another room for credibility in ignorance. The general idea is, while the computer has the access to the entire game state, a credible AI shouldn't have that knowledge unless justified. People who played Final Fantasy games might recall an ability called "Scan" that allows checking opponents stats etc. - such a skill is useful because these stats aren't initially known to the player. At the same time, the opponents don't use that skill on us; maybe because they are too dumb to make use of it, anyway (picking one of their available moves at random).

What I think would make for a credible and interesting AI is it acting like not knowing the player characters when meeting them, using Scan-like abilities during the encounter and using the newly acquired knowledge against the players (e.g. aim player characters with status effects it knows they're weak against, or give up status attacks altogether if it sees the given character is immune). That is, if the AI is supposed to be a person; I don't think random monsters are expected to have particular tactical insight, and in such case they'd be more credible just using whichever attacks comes first to their mind.

So, any other thoughts on designing AI?
 

trg601

Member
Well I think a good AI should include the immense variety you find when playing a multiplayer shooter. Humans are not easily predictable, and I think the same should be for AI; sometimes you get a very easy kill, sometimes you get killed easily, and sometimes neither you or your foe will die immediately, allowing you to learn about each other's strengths and weaknesses. I think a fun game could be made using enemies that don't constrict to certain patterns.
 
Z

zircher

Guest
While I have not committed it to code, on paper I have a plan where the AI makes it moves before the player does. [The game is simultaneous turn based.] It has limited intelligence but is smart enough to know where the player could go and build a heat map based on that and the available terrain and weapon systems. If there are multiple places to pick from, it will choose one of those to move to at random so the player is also left guessing.
 

Kepons

Lost The Bet
I haven't made any sophisticated AI, but I do like thinking about it. I praise games that bring the abilities of AI as close to the player's as possible. Of course, it's impossible to simulate a perfectly human-like way of thought, but what I mean is NPCs having the same means of defeating their foes as the player (minus real brain). In a typical RPG, you'd go around slashing tons of enemies in a mundane way. Sure, it can be fun, but if the enemies (at least humanoids) have access to various items like the player, for example, picking up and drinking health potions or changing weapons and armor, it gets much more interesting and challenging. In my opinion, whirling through hordes of enemies isn't as fun as fighting someone with access to the same features as the player.

This probably doesn't apply to all game genres and is really hard to implement fully, but I like the idea of it.
 
J

Jaqueta

Guest
I think that's interesting to add some randomness, but only at a certain point where it's still predictable for the player.
It's really frustrating not being able to understand the enemy in order to deal with.

For instance, you can have an enemy that is more aggressive, then you should make him look angrier with animations or sounds. If the enemy prefers to camp and wait for the player, he should stay silent and focused, or even with fear.

Other thing to take in mind, is how the player HP works, if the enemies have Hit-scan weapons, and the player won't be able to dodge all the attacks, it's recommended to have some way of regenerating that HP, with Medkits or even, COD regeneration style. If you can predict the enemy projectiles, or melee attacks (According to their animations), this is not even necessary.

You can even add weakness and strengths on your enemies randomly.
One game that accomplishes this very well (In a certain way) is Shadow Of Mordor. The "Bosses" are randomly generated, some have fear of fire, others hate it and get angrier, some can be easily killed with stealth, but others with animals.
However, you can discover what are they weakness and strengths before fighting them by searching for information in a number of different ways.
 

Ninety

Member
I really like TF2's bot AI. They don't always head towards the most obvious objective but spread out, use the geography to their advantage, and interact with each other in interesting ways. An AI isn't just "human" because it makes the occasional mistake on its way to the objective, it does things you can't anticipate and visibly interacts with the world around it. If I can tell the AI is designed to do the assigned task perfectly 95% of the time, and 5% of the time it'll stuff up completely, you haven't made a realistic AI, you've just made a robot that sometimes breaks.
 

HayManMarc

Member
I've always dealt with AI by assigning a set of skills to the AI and having them "roll to beat the percentage", as with old tabletop dungeon games.

My attempts have always been really basic with only a few skills, but you can add more, such as training, experience, health, energy, environment, etc -- and by calculating these together in various ways (balancing) you could get differing outcomes that seem plausibly intelligent.
 

Yal

🐧 *penguin noises*
GMC Elder
For most action games, I've had enemies have relatively rigid behavior where they only care about the player's position at most... for instance, in an old Megaman clone I did, bosses would alternate between shooting in the player's direction and jumping towards them. Since enemies have higher power priority than players (players take contact damage, for instance) in this type of game, this forces the player to study the enemy and figure out how it acts, then use this knowledge to approach the enemy safely. It's not so much the enemy acting smartly as the enemy acting in a way that allows the player to outwit them.

Speaking of imperfect AI, has anyone player Smash 4? (the official name being "Super Smash Bros For The 3DS / WiiU"). I've noticed the low-level AI characters more or less are max-level AIs that spend the most of their time doing nothing at all, then randomly drag you into a 10-hit combo if you're close. It can make some of the "fight hundreds of weak enemies" challenges much harder than expected because the AIs are so hard to predict. In earlier games, low-level AIs acted completely differently from high-level ones, not really telegraphing their attacks but using a lot of slow attacks that you saw coming. The Lv.1 AIs in Smash 4 uses proper combos out of the blue with no warning. It's definitely made by dummying down a properly working Lv.9 AI using random parameters and cooldowns.... and it's pretty obvious in gameplay. I'm not sure this approach for AIs is worth trying since it's so easy to mess up, it might be a better idea to work in slight inaccuracies everywhere in the AI than to alternate between working perfectly and intentionally failing... after all, isn't a humanlike AI supposed to not act binary?
 
F

Fodderbot

Guest
The AI I've been working on for my latest game looks at the particular mob and then integrates different decision trees for behavior based on the mobs intelligence level, natural inclinations and personal motivations. A stupid solitary creature that's just out for food reacts much differently than a social pack animal like wolves, or differently from an intelligent social humanoid.
A solitary dumb animal will attack if it feels it has the advantage if its getting to injured it will retreat. The threshold of retreat is based on its aggression
Wolves will attack if they personally have the advantage and if there are enough of them still around to allow for attacks during distraction by others after a few of them retreat then the whole group retreats, alphas thrown in also change this dynamic.
Humanoids work more in tandem and often support one another when in danger. All this peppered with a little random varied by personal stats.

Integrating multiple different, quickly traversed decision trees for each single creature keeps the processing time low, but makes the emergent behavior really interesting.

Instead of running all the creatures through a single ungainly decision tree that tries to take into account all possible variables
it approaches the problem from the opposite direction only making decisions on things that are important to individual creatures, thus culling out huge portions of the overall decision structure that now don't need to be processed.

The result of running through the decision tree is a goal that the creature will attempt to pursue until it "changes its mind"
the goals are easily translated into moves and actions.

This is less of an engineering solution and more of a behavioral model. Since I am limited with a limited number of actors in these interactions ( typically under 20) and the game is turn based strategy, the processing time is less of a restriction versus dealing with hundreds of mobs in an RTS sort of set up.

Engineering wise: Using ds_lists and stacks/queues makes traversing the decision tree lightening fast and gets away from huge numbers of switch-case statements and/or if-thens that would otherwise slow things down.

This is my solution to the perfect-dumbed down engineering model that always feels like its the computer cheating and never really feels like the mobs are thinking versus mechnaically reacting.
 

Alvare

Member
AI is at it's best when it's conclusions are non-scripted. When every time you repeat the scene, something different happens. Not because you were standing somewhere else, but because it does random things based on thinking patterns.
Important aspects are; pathfinding, variety of animations connected to lots of events (The more the ai can do the better) and responsiveness to player and environmental situations.

What I find most rewarding from enemy AI f.e. is that the ai out-smarts the player at first, puts the player in danger of losing the game and makes it difficult to win but just enough possible for that outcome to happen.
 
F

Fodderbot

Guest
AI is at it's best when it's conclusions are non-scripted. When every time you repeat the scene, something different happens. Not because you were standing somewhere else, but because it does random things based on thinking patterns.
Important aspects are; pathfinding, variety of animations connected to lots of events (The more the ai can do the better) and responsiveness to player and environmental situations.

What I find most rewarding from enemy AI f.e. is that the ai out-smarts the player at first, puts the player in danger of losing the game and makes it difficult to win but just enough possible for that outcome to happen.

And then again Retreat should always be a viable option. :)
 

Xer0botXer0

Senpai
Thank you very much for this thread, I learnt a bit that will greatly improve my game. :p when you talked about scanning and stuff, I don't want players to just access information.. I want ten go to the appropriate measures to find that information in the most enjoyable manner. One example, which faction is that player in ? Oh look he carries a banner, so he is in one, have I seen that banner before ? Who else carries that banner ? So players would in this example be able to create their own banners with layers and transparency where perhaps the last layer this faction leader or designer thinks okay what if I add rank symbols to this, so we have multiple banners and these banners depending on the symbol on it alongside the rest of the banner art will show which rank this player is and what his role is in the game.. Much better than right click and info and bam oh okay he's in that alliance. I may even go as far as when pkayers purchase things that are over a certain amount it'll have a little timer to show that the money is being counted. Or the merchant will notify you that he's just counting it or something instead of bam bought.. There's excitement from okay I've got it but there's even more when you see the process happening and feel engaged in this new purchase.
 
A few years ago I started developing a strategy game where the computer would adapt every time the player abuses a certain tactic. This worked kind of like a rock-paper-scissor game, except that if you abuse rock for a mission, in the next mission the computer will come up with a steel-hardened paper and you have to rethink the whole system to come up with some kind of out-of-the-box scissor.

Never got around to finishing it though, but i thought it would be cool to have an enemy that adapts to what you did in the previous mission.
 

Yal

🐧 *penguin noises*
GMC Elder
Never got around to finishing it though, but i thought it would be cool to have an enemy that adapts to what you did in the previous mission.
Reminds me of Warning Forever, a boss rush game. Basically, you start out fighting a single round core, and each time you beat it, it adapts to your strategy. If it manages to kill you with a certain weapon, it prioritizes upgrading that weapon or add more copies of it, and it adds more segments/armor to whichever body part you destroyed first. It's really interesting to see how it adapts to your playing style to force you to spice up your strategy.
 

Alice

Darts addict
Forum Staff
Moderator
Right, adapting to player behaviour. Another thing I considered, probably quite advanced, would be having the enemy prioritise the player character that e.g. deals most damage overall, or the one that is identified as team's healer. Another matter altogether is that different enemies would have different insight (e.g. some might not understand healing magic) and different strategies (e.g. some would just attack the player that dealt the most damage recently). Some of these scenarios might be pretty advanced to pull off, but some other should be actually relatively easy.

Also, when confronting some action-game style boss, I think it would be pretty cool (and relatively easy to implement, to boot) if the boss identified which attacks have the highest success rate (with base success rate of, say, 50%), and then prioritise these (maybe not by spamming that attack all the time, but by it having significantly higher probability of being used in the next move). With that, there's little chance that the player will get away scot-free by RNG picking the easier attacks, especially if the boss at the beginning shuffles through its attacks, making sure that each is tested against the player.
 
Top