PDA

View Full Version : AI for the Banner Saga (and Factions?)



Yth
05-02-2013, 08:02 AM
As the devs have mentioned they will soon begin working on the combat AI for TBS, I have been thinking about the topic. I know that several members of the community are interested in AI design, so even if the devs already have a complete idea of what they want to do and how to do it (I would certainly hope so!), this topic may still be fun/interesting to think about.

I ended up writing pages and pages of thoughts related to AI design, difficulty, and in-story reasons for the actions of the AI controlled units. If you are interested in the topic, you can give the whole thing a read, but my overall point would be:

The game's difficulty should be challenging (with options to lower difficulty as needed). While the combat AI is only a part of the overall difficulty of the game, the challenge of facing combat AI should be adequate. It would be thematically pleasing if the in-game lore matches to and explains whatever level of intelligence the combat AI expresses.

Sub topics to be each discussed in their own replies:
AI design: the ideal
AIs and game difficulty levels
AI mechanics
AI & Lore, or the in-game explanation of AI

Yth
05-02-2013, 08:02 AM
AI design: the ideal
Basically, if the combat AI gets to the level where an enemy unit is smart enough to move up to block an important tempest and make you waste your WH's turn, I will be very happy.

In order to do this, the AI would have to be able to weigh options for possible moves for the current unit + at least the next 11 units to move (assuming a 6v6 fight), evaluate the best (numerically highest) damage options available, and weight them against the best damage options available to the opponent, to determine if an offencive move or a defencive move is appropriate.

In other words, it doesn't make sense for the AI to send an archer unit charging forward in order to do 3 damage, when it would take 8 damage in return for exposing itself. But it might make sense to move the unit forward to prevent a 12 damage hit which would otherwise be incurred.

When moving offencively, the AI would consider zones of threat, opportunity costs versus returns, potential enemy countermoves (including horn usage for extra mobility)...

Defencively, the AI would have to consider the same as above.

Failure to account for these (and other) factors would result in a combat AI which is relatively simple to beat: if the AI does not position its units to support each other, you can bum rush them and pick them apart. If the AI does not prepare for a forge ahead + WH combo, or a push + WH, it will be trivial to land a strong tempest every time and clean up based on pure numbers.

Yth
05-02-2013, 08:03 AM
AIs and game difficulty levels:
Generally speaking, the combat AI of most games falls far short of the ideal. This is with good cause: it is incredibly difficult to build up a system which can challenge an expert human on equal footing. Most games compensate for this by introducing difficulty in areas other than combat AI. Some examples include:

1) mitigation: you don't have to win 1 battle, you have to win 10, and damage taken in each battle is carried on to the next. Each small loss adds up until by the end of the series, you have a signifigant numbers disadvantage and must fight to eke out the highest effectiveness from your remaining units.

2) numbers imbalance: a variation of 1. Your force of 6 units fights their force of 10 units, or each of their units is some % stronger than yours. It comes down to the same thing, that the player is expected to out perform the AI on an individual level, so you give the AI unfair numbers to compensate and provide challenge.

3) intricacy: some games aren't truly challenging, they just throw so many details and rules into the mix that learning to properly use all of the game's systems takes as long as it does to complete the game.

There are, of course, other many other examples of game difficulty being seperate from combat AI difficulty.

Once again, ideally, the AI should be smart enough to challenge highly skilled players on equal footing. If this is accomplished, the game's difficulty can be decreased by having an AI difficulty slider, or by giving the player numbers advantages similar to those listed above.

The point is, you can create a challenging game experience even if the game's combat AI is not the best. But the best and most lasting game experiences are where you are challenged without feeling that the game is "cheating" by giving the AI side unfair advantages.

Yth
05-02-2013, 08:04 AM
AI mechanics:
Here are some different mechanical approaches I dreamed up for a Factions AI. I'm sure professionals (the devs) will do this on a much more practical and useful level, but I had fun thinking them up:

Threat analasys based approach: account for the largest stat value hitters on several levels:
1) the largest threat to the team that is reachable by the current unit
2) the largest threat overall, to be maneuvered towards or to be combo'd down by several teammates
3) secondary threats, with their difference in threat level valued versus the amount of effort it would take to pounce on the largest threat

Tactical competence based approach:
The AI accounts for the tactical situation, and makes a turn-by-turn decision based on possibilities and numerical advantages. On the most basic level, the AI would consider the next X number of turns, to find the most effective way to utilize the active AI unit together with the next X allied units.

Example: Doing 2x break 1x hit on the Warhawk will deal 6 armor 10 strength damage, and prevent 10 str damage. Doing 1x break, 1x hit on WH, 1x hit on an archer will deal 3 armor 6 strength, and prevent 12 damage. Evaluate different options for highest number total and execute.

Hurting the player as much as possible based approach:
AI which does actions not to win the round, but the cause the player the most hurt. In the larger game, if a unit is cripped and gets stat maluses for being brought to 1 or 0 str, the AI will seek to perform this and only this as much as possible, since it knows it is designed to lose all its matches and will therefore do its best to cause any economic damage to the player's units... This increases game difficulty at the cost of high frustration for the players. Not recommended.

Yth
05-02-2013, 08:05 AM
AI & Lore, or the in-game explanation of AI:
Looking at AI from a completely different perspective, you could approach AI design by first asking how the intelligence you are trying to emulate through in-game programmed AI actually works. Are you emulating a thinking being with lots of battle experience? A created construct with combat ability that comes from the magic that helped create the construct?

Depending on what you are trying to emulate, and especially regarding constructs, it can become acceptable if the AI is very stiff or limited: you are emulating a construct with a very limited amount of battle awareness. Depending on the lore-choices made in designing the dredge, the in-game AI could be created to match.

As I am not aware of the full lore behind the Dredge and who/what they are, here are my dreamed-up possibilities:

1) The dead spirit of a great warrior is bound to a construct. When you tell the construct to fight, it fights with the ability/tactics of that specific dead spirit. Can have several problems: the spirit is unwillingly bound and therefore will not fight to the fullest of its abilities, or the spirit could recognize a descendant and commit suicide instead of killing him/her.

2) A piece of the spellcaster's mind/essence is bound into a construct, or a minor copy of the involved mind is made. The construct acts as you would, with your own tactical/fighting abilities. For the most part, this option is bad in that most magicians have poor combat skills and reflexes.

3) A general all-purpose pseudo intelligence is described by the systems of your spell (probably inherited from the master who taught the caster magic). This would have algorithms or a programming system very akin to a modern AI. This would signifigantly increase the complexity of the spell needed to create the construct, but would avoid some of the problems associated with binding a spirit to the construct.

4) The constructs act with no autonomous will, and must be manually directed by an operator, who is:
4a) the original spellcaster, directing his troops, 4b) any person with the proper talisman/magic words/permissions, directin the troops, 4c) an animal/person/whatever, bound into/onto the construct, directing it (golems of death and destruction piloted by small woodland creatures, anyone?)

5) The dredge are actually a race of magical golem-creatures, with shared perceptions and a hive mind. They work frighteningly well together as a unit, and will willingly sacrifice one or many warriors when it is necessary. Shouting out "Resistance is futile" is optional.

StandSure
05-02-2013, 08:41 AM
I heard that Stoic is going to forgo AI and just kidnap Tirean, lock him in a room, and make him play as Dredge vs. everyone 24/7.



1) mitigation: you don't have to win 1 battle, you have to win 10, and damage taken in each battle is carried on to the next. Each small loss adds up until by the end of the series, you have a signifigant numbers disadvantage and must fight to eke out the highest effectiveness from your remaining units.

Based on a lot of the previews of the Saga and the intent toward the story, I think there will be a big element of this. My impression is that you will be able to make choices such as "make camp and rest after that battle, OR plow onward, hurt, and risk fighting again" with consequences to moving too slowly as well.
Actually, within the context of the story this seems like an effective way to handle difficulty levels. Rather that choosing a handicap at the beginning of the game, you can self-meter your combat throughout by choices you make. That way, the Dredge can fight at an expert level (and be feared as they should) but you can affect your gameplay to encounter them less often if you are not an expert-level player. Your story will be different, but you will not feel trapped by a ruthless AI. Meanwhile, the experts can go on a Dredge-hunting rampage to satisfy their bloodlust.

Evil Laughter
05-02-2013, 09:18 AM
Ok I feel I should chime in here. Let me preface by saying I'm not an expert on computer game AIs, but I am in my third year of a PhD on machine learning and I have masters degree in AI based system control. SO what you have describe in AI mechanics is called a rule based system, there are several ways about going about collecting the rules but basically it would mean that the AI would be predictable (think early chess programs). What is far better is some statistical model that can learn from games that have already been played, and the devs have a large sample of games from factions.

If you want I can go into details about how an expert system can be trained using this data, but a simple way to create different difficulties would be to train AIs on different games. Conveniently there is a scaling system in place for how good the quality of the players is, their ELO. Anyway that would be how I would make a game AI.

raven2134
05-02-2013, 09:44 AM
Interesting post Yth.

We got to chat a bit on the AI with Arnie in the chatbox about this stuff :). AI isn't quite gonna head in the direction of your post. He was hinting that it's likely the AI will play out in ways similar to a puzzler but not one that's repetitive (like once you solve it, that's it).

I think you can look at the puzzlers franknarf and Tirean post now and then. You can find yourself in situations where good decision making and smart plays do great things, and it's different from match to match. I think that's where Stoic wants to head with the AI. Repetition or "one solution" can be avoided same ways we see in Factions now, where variability and difficulty is organic due to different builds, positions and stats. There's a lot of potential to explore in short.

I personally hope the Ai manages to be reactive and forces player's to think and adapt. If the game manages this I think it will be plenty good. If it's up to the player to string together the correct sequence and choices to prevail, and doing so means you end up not hurt much, that's a testament to skill and experience. Dark souls was much the same way. The penalty for messing up just needs to be scaled right ;)

Aleonymous
05-04-2013, 10:49 AM
DISCLAIMER: Please keep adding "in my opinion" as you read each sentence in the rest of my post! :)

AI is perhaps one of the most crucial parts that contribute to the lasting enjoyment of computer games. That's why it's really tough to get bored of Factions (or any other human-vs-human game, for that matter): because you're always facing something new, something different. So, the crucial aspects of a successful AI-design are:

diversity
adaptability
reactivity
unpredictability

It's not just making a difficult-to-beat AI (like the Chess-AIs), but making an AI that emulates many of the facets of an "interesting/challenging adversary". Incorporating these elements in the AI design, along with Yth's or Evil-Laughter's classical approach to "difficulty" (for instance, controlled with respect to the "movement depth" it calculates, or the repertoire of combos/tricks it is allowed to access), is surely to make battles highly enjoyable. Throw in some drama, e.g. having difficult choices to make between equally bad consequences or fighting unsurvivable battles, and then we're up for truly unforgettable experiences! :rolleyes:

Now, let me describe the above points more in detail:

Diversity: Essentially, this refers to different battle scenarios, and reflects the motives of your opponents (i.e. the reason of the fight). Examples: Protect an ally, attack closest target, kill a specific target, maim/kill as many as possible, delay them, beat them as a group (just what counts in Factions) etc. This is perhaps the most important aspect of AI.
Adaptability: This means that the AI controlling a fixed team should handle different opponents differently. Examples: Goblins are very cowardly when outnumbered and prefer ranged attacks, but when they have the numbers they are prone to reckless assaults. Dredge-AI just as Yth described it. Human raiders or kingsmen are expected to behave differently, have racial enemies etc.
Reactivity: Emotion is expected in a combat (except when fighting robots/dredges?), and this is to say that the enemy can potentially change his tactics (his AI) when "something happens". For example, when their leader is killed they might flee/surrender, or attack only the person who killed him, or go in a rampage/berserk rage etc. These aspects can be also diversified to limit repeatability and add depth
Unpredictability: This is difficult to describe. I am talking about making intentional mistakes, having luck chime in, experiencing some divine intervention and other aspects that cannot be categorized easily. There could be plot-elements or hidden-motives related to this unforeseen events, but they should not be known to the player before they manifest themselves. The element of surprise


In overall, it's a great thread idea Yth! :) Hope the devs will shed some light in this area, or just plainly surprise/astound us when the game is out!