AI Players in Games

I had this interesting conversation about good AI in games which was pretty cool and here's my attempt at reflecting on some of the points raised. It may not be completely 'correct' in the sense of the conversation topics, but I hope it gets some of the point across:


AI players are an interesting subject in videogames. Players don't like to play against what they perceive as an AI simply because it doesn't feel good, but why? Often times AI in videogames are partially perfect - they have instant reaction, an encyclopedia of the game's rules and sometimes rigid methods for dealing with solutions to achieve a goal. At the same time though they may also lack in certain forms of awareness, such as repeatable actions.

Take for example, when I was younger I'd play a lot of Super Smash Bros. with other people. We'd punch, kick and use one or two special moves but as soon as someone used a shield and the other player remebered to grab, that function would suddenly be remembered as a thing by both them and myself and we'd proceed to keep trying to throw each other. Why? Because unlike an AI, humans don't have an instant recollection of everything. We care about what's relevant to us and the moment and react accordingly. When two characters clash, the attack animations of both cancel out and they both stand in default positions again. This sudden change in the flow of fighting often comes as a surprise to even professional smashers, but a basic AI simply chooses its next move - with no element to surprise or reaction.

A human player has a classic reaction time of something like 0.2 seconds. As you play a game you build up expectations over that course of time, but when it doesn't happen the way you expect you change your plans when your actions catchup - like stopping a car when an unseen pedestrain crosses in front. Games like Overgrowth have looked at this issue, where for example the AI has a split second delay over where it thinks you are going and what it actually sees, and moves in accordance of what it assumes will happen next, allowing quick changes in direction to fool the AI for a brief moment. However, going too far with this simulation of human behaviour also causes another problem of making the AI's mistakes too repetitive and thus making it still seems like an AI.

The keye here would be making the AI learn and adapt - little knobs and buttons to tweak AI behvaiour dynamically. If you throw lots of punches the AI will build up a list of your actions and try blocking upwards all the time, but if you change tactics and move to sweeping kicks the AI will try to choose what it thinks you are most likely to be doing. This idea is all about not making the AI stupid, but giving it human limits. Most players cannot remember everything in one go, and that memory is sorted by relevance which reduces with time. When we react to things, we slowly form a habit of doing that thing, and so too should an AI. A rigid AI that always follow a set strategy with minimal randomness, regardless its "technical" in-game skill, is still seen as a simple computer program. But if the AI has a list of strategies and habits, modified by initial settings and changing as the game progresses, you get a much more dynamic "character" that helps to convince the player tha AI may be intelligent.

Of course, these are games - you are not trying to build an artifical brain. But you are trying to emulate a player. As such, an AI should do in a situation what a human player should do, and that does not necessarily mean make mistakes. If an attacking character does a strong attack with a long cooldown before it can act again, the majority of players will be focused on former fact of dealing with the avoidance of damage rather than capitalising on the latter fact that the opposition is open afterwards, not until they get around to it anyway. The key thing to understand is that AI should be like a "partner" or "rival" to the player, as part of the all encompassing aspect of game balance and progression.

Another interesting thing to note is distracting the player. A really good example of this is the case of Resident Evil 5. As long as you are online and have the feature enabled, random players can join your solo campaign through Agent Hunt - as various enemy mooks. Other than a message saying a player has joined, the human player(s) have no indication that an enemy is AI or human controlled. When an enemy acts like an AI we categorise that as such, but this also means we expect things that aren't the enemy to be not an AI - like your partner (assuming your partner is a human also, because otherwise you'd also expect them to be AI from their behaviour). So when that random enemy zombie acts out of the ordinary by running away on low health rather than mindlessly attacking, players can often get confused: Was that an AI? Could it be a human player? AI doesn't normally do that!

A case (I can't find the link atm) in a game that highlights the classic misunderstanding of what makes a good AI had the developers record a perfect lap of a racetrack by a real professional driver and put it ingame as an AI. Players apparently complained that the AI was unrealistic, that it followed a perfect track and was unbeatable. True enough that's what the driver did, but the point was that the players felt it was too perfect and complained as such. AI cars in racing games don't ever seem to crash as they follow as 'correct path', but this doesn't happen for players. They simply follow the road in front of them, but until they know the course better that's the best they can do. This 'perfect' rigidity is often the downfall of many AI in games.

Making an AI that appears to adapt or change makes it more believable - more human. Say you play a game solo, and you want to play against an AI. Instead of fighting against 'AI: Normal' I want to fight against 'AI: Jimmy', whos personality saves between matches. This concept of an AI being an individual emulated player of habits and learned strategies is similar to a very basic form of the Amiibo things that Nintendo has made for Smash Bros., as they learn very basic actions from battling by changing little knobs in reaction to events such as "Oh, I got hit by an attack so I should try to shield a bit more". By increasing and decreasing weightings of different strategies an AI can appear to have a consistent and semi-reliable but not 100% predictable pattern that is wary of simple AI potholes like falling for the same trick 1000 times.

Likewise, an AI's difficulty does not have to be simply bound by the speed by which is can handle the game's rules. After all, some strategies work better than other but are also sometimes harder and riskier to pull off. Say I was playing an RTS game like Supreme Commander. If I fought an Easy Rush AI, it would implement an simple strategy of simply gathering some reasources then sending a mass of just tanks towards my base in an attempt to rush me before I can deal with it. However the problem also have a simple solution of simply having built an anti-land defence. However, if I were to play against a Hard Rush AI, it would gather its resources as quickly as possible and build up a mixed army of land, sea and air and rush at once, covering all three fronts in order to quickly and swiftly bring about my demise. Same strategy, but more advanced and utilising more concepts that a better player would know well but a new player would struggle to understand.

I've run out of things to say, but I can conclude that AI is not about trying to be a player. An enjoyable AI in games is one that works at the same level as you. By having this competition, the player is motivated to achieve more. Say the AI 'Bob' has a 60% win rate against you - and you finally beat it to the point where you are now evenly matched or even beating the AI. But the AI also recognises the increase in skill and subtley changes its weighting based on how the game has gone so it have a just little bit higher win rate than you again. This gives a new goal for the player, and is part of a wider issue that is dynamic difficulty. After all, players play games for the sense of enjoyment, competition and achievement. If the AI can help me to obtain these experiences from a game, its a good enough AI for me.