AI and the Single Player Game

Basic Decision Matrix

Let’s take a look at a simple decision matrix for an RTS.

  Rush Produce Defend
Rush 0,0 1,-1 -.8,-.5
Produce -1,1 0,0 .8, .2
Defend -.5,-.8 +.2,+.8 0,0

Your action is on the left, theirs is on the top.  The numbers say how much you can expect to gain (first number) and how much they can expect to gain (second number) for that combination.

So, if you rush an opponent that’s producing/expanding, you should expect to win.  Other combinations are less drastic, and if you do the same thing your opponent does, it’s a draw.

Should I Stay or Should I Go?

Based on some weighting mechanisms, the AI is going to determine what is the best strategy to use.  At first glance, it looks like rushing is the best strategy.  The loss you suffer from a defending opponent is bad, but not terminal, and you can dominate an expanding/producing opponent easily.

But, that’s not the whole story.  If the computer always does what the best option is, then this can be taken advantage of - the computer, in this case, will always rush, and so the human player can always defend and get an early lead.

This is the danger of AI today - it’s predictable.  And while this is a pretty easy situation, the same pattern emerges in most games.

Looking at the three stages of decision making, we take out the stage of actually making the decision.  Once we’ve got a workable decision matrix, we can determine what the opponent will do, and so we can determine what we should do… in this case, we know the opponent will rush, so we should defend.

Most players, admittedly, aren’t going to think about things in this way, and even then, I highly doubt that they’ll actually draw up little boxes.  But, at some level, they’ll internalize these concepts.  That’s why playing against humans is so different from playing the computer.

Why’s It So Dull?

Decisions aren’t easy if there’s a playbook.  You can play blackjack in Vegas and get these little cards that will tell you what to do based on the cards.  And that will get you optimum odds outside of counting.  And guess what?  It’s boring to do.  It’s Progress Quest, only with drinks.

So, what can we do?  There’s a few things that can be done to keep games interesting.

  1. Make ‘em hard.  I mean, Nintendo Hard.  Even if you know what to do, crank up the difficulty so much that doing it is still a pain.  This is basically emphasizing the execution stage of decisions.
  2. Vary the challenges.  Throw enough different things into the mix that the player constantly has to re-evaluate his strategies as he faces new combinations of opponents/whatever.  This forces players to re-analyze their gameplan significantly, as the old models fall apart.
  3. Complicate the analysis.  Add lots of factors, so that the player has to worry about a lot of things.  This also targets the analysis stage.
  4. Make AI that actually reasons about things and understands higher-order decisions.  This may not always be optimal!  It’s a lot of work, and sometimes, players want AI that’s predictable, so that they can learn how to defeat them.

The usual game seems to take option 3 - making the game more complex.  This often shows up as additional features or extra moves.

Unfortunately, this also has the effect of killing genres.

Personally, I think some combination of 2, 4, and 1 (in that order) is the way to go.  Make challenges that are different enough that they feel fresh - this is where truly good designers come into play.  Make the AI at least a little unpredictable, and then make the game hard in general.

I’m Sorry Dave, I Can’t Let You Have That Gold

You can probably make reasonably good AI reasonably easily.  If you can build a decision matrix like the one above, the AI can choose randomly from the choices based on the overall effectiveness - in this case, choosing to rush frequently, defend infrequently, and expand rarely.

This kind of basic randomization can work.  One old text-mode game (that I believe ran on Novell) featured enemies that, players claimed, set up ambushes, and were nearly psychic in their ability to sense the player’s plan.  In reality, they just did the most obvious movement, except for a small random chance that they would do the opposite.

Design

Comments (4)

Permalink

3 stages of decisions

It seems that, in general, there are 3 stages of decision-making.

  1. Analysis
  2. Opponent
  3. Execution

 Analysis

The analysis stage is about gathering information.  This doesn’t have to be done at the exact moment of the decision - it’s based on all information gathered to that point.  Once the information has been gathered, it has to be analyzed, to turn it into a series of likely outcomes, dependent on what your opponent does.

At the beginning of an RTS game, if you assume the “classic” 3 choices of defend/expand/rush, the analysis stage would result in how much you’d gain or lose based on each option, for each choice that your opponent could take.

Opponent

Once you’ve analyzed the information available, you have to make a decision.  Obviously bad choices are simply thrown away - choices which may be better or worse dependent on what your opponent reacts are considered.  This is where a lot of the “mental game” occurs in any game - figuring out what your opponent is going to do, or leading him into thinking you’re going to do one thing when you actually do another.

Execution

Once you’ve decided what to do, you have to actually do it.  This is the area where pure skill comes into play.

Emphasis on differing stages by game

Different games place different emphasis on stages of the process.  The execution phase is essentially non-existent in chess, while it’s always a large factor in bowling.

Even variants of the same game can place different emphasis on various stages.  For instance, 7-card stud poker places a great deal of emphasis on the analysis stage, while Texas Hold’Em streamlines the analysis stage and places a greater emphasis on the opponent stage.  And neither of them are particular based on skill, in the “pure physical” sense.

Emphasis on differing stages by player ability

Players also seem to emphasize different aspects of the decision making process, even within the same game.  For a game which includes all three stages of decision-making, the order in which players emphasize them (lowest skill to highest skill) seems to be:

  1. Execution
  2. Analysis
  3. Opponent

This makes sense.  At low levels of skill, the ability to effectively perform a technique will be more important than choosing the right action to take.  If both players have little skill, a successful execution will be somewhat rare, and so the cost of choosing a poor action is not immediately apparent, while the results of performing the technique well are.  Games played by players at this ability level are often characterized by an extreme focus on offense, and of attempting any “scoring” opportunity, no matter how improbable.

Once basic skills have been mastered, good decision-making becomes the next most important aspect.  A player at this level will start to see the consequences of his decisions, as his opponent becomes more able to effectively take advantage of his mistakes.  Analysis of the situation then becomes more and more important, as weaknesses in the opponent’s play can then be taken advantage of.  While skill, and increased skill, still are valuable and provide an advantage, bad decisions can nullify them, allowing a lesser-skilled (but still competent) opponent to win.  Games played at this level become characterized by an increasingly well-organized and tighter game, relying upon their opponent to make a mistake.

Once both players are able to analyze the situation effectively, the game becomes, primarily, a mind game.  At this point, you are considering what is the likely outcome based upon what your opponent will do.  Simply making the “best” play is no longer enough, as your opponent will expect it, and be aware of how to counter it (assuming that the game isn’t horribly broken, that is).  This is also the aspect of decision-making that game theory primarily covers, as it assumes both players are capable of executing decisions, and have the ability to analyze the outcomes accurately.

This is the highest level of gameplay.  At this level, the general rules discovered in the previous stage become a starting point, rather than an absolute.  At this stage of the game, the players become more actively involved in influencing the play of their opponent.

Computer and video games, and the three stages

Generally, computer games have AI that is very predictable - in a given situation, it will always make the same choice.  In some games, the opponent is a system that is designed to be entirely predictable.  Because of this, solo computer games typically emphasize the analysis and execution stages of decision-making.

This is somewhat interesting, then, because if your opponent is predictable, then any given scenario will always result in exactly one best decision, for any set of circumstances.  The game becomes learning how to analyze the best decision to make, and improving the ability to execute it.  As players become better at the game, the only way to increase the interest level is to either require higher levels of skill, or introduce more factors into the decision-making process.

Both of these options have the unfortunate side effect of making the games less accessible to new players.  At the early stages of this process, new players will have a more difficult time getting into the game.  However, as this continues over the course of years, eventually the games will become so complex that new players will be all but unable to learn how to play the game.

Complexity and depth

We hear these terms a lot when dealing with games.  I’m going to try to define these:

Complexity refers to the difficulty of analyzing the available choices.

Depth refers to the number of choices available that are not dominated strategies.

BTW, “dominated strategy” refers to a choice that, no matter what your opponent does, is inferior to a specific other choice.  In rock paper scissors, there are no dominated choices.  If you add in the “bomb” (blows up rock and paper, fuse is cut by scissors), then the choice of paper is dominated by the bomb.  No matter what the opponent chooses, “bomb” always does at least as well as paper if not better, so there is no reason to ever choose “paper” if “bomb” is available.

If we assume a predictable AI that will always choose the same option in a given situation, then that game can only increase in complexity or skill, not depth.  That’s not necessarily a bad thing.  One of my goals in this blog is to not make judgements about what is good or bad in games or game design, but to rather help devise a framework that can explain observations.  Increasing in complexity is fine, so long as you’re doing it deliberately, and for a specific reason.  But, be aware of the side effects of increased complexity, especially the increasing difficulty to attract new players to the game/genre.

Design

Comments (2)

Permalink

Opportunity Cost

Opportunity cost is a very simple concept.  The opportunity cost of any action is any other actions that are then precluded.

If I have one hundred dollars, and I use it to buy a bicycle, the opportunity cost of that purchase is all of the other things that I could have purchased with that hundred bucks.

When looking at games, and specifically decisions within games, it’s a useful concept, as thinking about the opportunity cost of a decision can help us define what the actual decision is at any point.

If a decision has no opportunity cost, then it’s not a decision.  This is rare - usually, even *not* doing somehting is a viable alternate, and so the opportunity cost of any action is, generally, that you lose the ability to not perform the action.

As an example, if casting a particular spell is free, and that spell has some lasting effect on the player, then the opportunity cost of casting that spell is *not* having that effect on you.

For another example of how thinking about opportunity cost can help in game design, let’s look at RTS games.  In a typical RTS game, you will have some type of gatherer unit that collects resources.  A typical decision early in most games, is whether the player should build more gatherer units, start building offensive units, or start building defensive units.

Any of these choices does not preclude you performing the others in the future.  Building production units at the immediate moment doesn’t stop you from building offensive or defensive units later - in fact, it makes it easier.  In many games, you could actually, to some extent, build all three at once.

So, what’s the effect of building production units early?  You get an early boost to your economy that (generally) will give you an early bonus in production, assuming that you live long enough to see it.  Similarly, early production of offensive units gives you the ability to do an early attack before your opponent has had a chance to build any defense, and early production of defensive units will defend your base against an early attack.

When you look at these three choices, the traditional 3 early game strategies (expand, rush, defend) become very obvious.  The opportunity cost of “early production” is early defense and offense - you become vulnerable to an opponent doing an early attack.  The opportunity cost of early defense is production and offense - you can’t take advantage of your opponent if they don’t defend early, and you lose any production boost you could use against a defensive opponent.  The opportunity cost of early offense is that you don’t get the production boost, and are still vulnerable against early attacks (although you can meet the opposing force head-on and at least have a chance).

Another interesting place to look at opportunity cost is MMO abilities.  In typical MMOs, abilities have sufficiently long reuses that casting a spell or using an ability does not, in any meaningful way, preclude using the other abilities.  And, with the generally slow regeneration of power, abilities usually don’t cost enough power for power to be a truly first-tier consideration in what you should do.

So, what’s the opportunity cost?  Generally, it seems to be tied to a few things:

  1. Time to execute the ability.  Since, in most MMOs, abilities hav an execution time that prevents you from doing other activities, the opportunity cost of an ability is the fact that while it prevents you from doing other things during that time.
  2. Side effects of the ability.  Casting a large, damaging spell may have side effects such as angering the opponent so that it will attack you.  In many cases, this is undesirable.
  3. Abilities that are mutually exclusive.  This is often seen in “stances” that some classes can take which are mutually exclusive, but it can also be seen in spells where a spell can prevent another type of spell from being cast on the same target, either offensively or beneficially.
  4. Power can be a consideration, as it can prevent you from casting other spells, but this usually happens later in the fight (especially when things have already taken a bad turn)

BTW, opportunity cost is an economic term, and you’ll be seeing a lot of things from economics in this blog over time.  Mathematical game theory is often used in economics, and games are often about resoure allocation, which is, in many ways, what economics is about.

Design

Comments (4)

Permalink

Opponents and Games

Opponents

All games have opponents.  A game without an opponent is a space, or a toy.  A challenge to overcome defines a game, and is what makes it separate from a space or a toy.

There are two main “types” of opponents, symmetric and asymmetric.

Symmetric opponents

A symmetric opponent is simply one that has the same level of relative power as the player, usually by virtue of them just being another player themselves.  The abilities of a symmetric opponent do not have to be the same, so long as the overall power is roughly equivalent (in other words, minor imbalances don’t impact this.)

Asymmetric opponents

An asymmetric opponent is an opponent that has a vastly different power level than the player.  They are also, generally, designers or developers rather than other players.  Most single player games are based on an asymmetric opponent.

Opponents and gameplay

This leads to a couple of different types of gameplay.

For a symmetric opponent, games should be 50/50.  There’s always a significant chance of loss, and the game has to be developed with that concept in mind.  If you play tennis, you know you’re going to lose a good amount of the time, depending on your opponent.

For an asymmetric opponent, there is no challenge for the opponent in beating the player.  Since the power differential is so high (possibly infinite), there’s no point in “beating” the player.  Instead, the role of the opponent is to provide a series of challenges to the player.  This means that, in general, the player will have an expectation of eventual success against the opponent.  People expect to be able to beat crossword puzzles and single player games.

Power symmetry and gameplay symmetry

Symmetry here is about power, not options or playstyle.  As an example, in Dungeon Keeper, the single player game is asymmetric - the player is faced with a series of predetermined challenges.  This is asymmetric, as the designer has the ability to develop the challenges however they want.

However, the multiplayer game in Dungeon Keeper involves one player acting as the “keeper”, and basically playing the same game as the single player game, while another player takes the role of the invading heroes.

The multiplayer game is power-symmetric, even though the “hero” player is playing almost an entirely different game (is gameplay-asymmetric).

Skill and symmetry

Skill of individual players does not make a game symmetric or asymmetric.  If the Dodgers play a little league team, the game may not be fair, but it’s still symmetric.  Both teams are playing by the same rules, and have the same options.  That being said, in cases of extreme disparity (such as the one above), one team can decide to make the game asymmetric if they treat it that way.  For instance, if the Dodgers were to place rules on themselves that were designed to be beatable by the little league team, they have changed the fundamental nature of the game.

Power symmetry by changing sides

Power symmetry can also be achieved given two sides of unequal power, by switching the roles.  In a gameplay situation where one side has an advantage, symmetry can still be achieved.  To do so, reverse the roles after the initial ’round,’ and play another round.  Determine the winner based on some measure such as time taken to win, or some other sort of score.

This is frequently done in team-based FPS games, generally in scenarios where one team is an attacking position and has to achieve some goal, and the defending team is at some inherent disadvantage.  This is a useful technique in these situations, as it allows designers greater freedom in scenario development without having to worry about giving one side or the other an advantage.  By switching sides, the game evens out in the end.

Design

Comments (0)

Permalink

So, what about decisions?

If a game is a series of decisions, then we need to ask what makes a good decision.

A decision that’s obvious isn’t a good decision (unless it takes skill, or you don’t have much time to make it).
A decision with no consequences isn’t even a decision.

I could do this for a while, but instead I’m just going to assert: What makes a decision interesting is it being a hard decision.

So, what makes a decision hard?

  • Time constraints
  • Number of choices
  • Number of factors to consider
  • Severity of consequences
  • Duration of consequences
  • Skill required

That’s at least a good start. With that, we can say that the difficulty of a decision is something like:

D = n-choices * n-factors * severity * duration * skill required / time allowed

What’s interesting here is that most of these things can vary based on the player.  Skill certainly can.  The number of choices may not seem to, but experienced players can immediately reject a number of choices for many situations, so that they are only focused on a smaller subset.  The factors to consider can similarly be reduced by a player that knows what is, and is not, important for a given situation.

Severity of consequences, length of consequences, and time required may not seem to vary, but I think even those can.  A good player may know how to mitigate the effects of a poor decision, reducing both the severity of duration of consequences.  Even time factors can arguably be mitigated, as a better player may have seen the decision coming in advance, and can have already been considering the appropriate action to take.

So, what value is any of this?

It gives us a way to analyze a decision, or a series of decisions, and describe how or why they are interesting or uninteresting.  If a section of a game is too hard, we can use these rough metrics to try to define *why* it is too hard.  Is it because the player isn’t given enough time?  Because there’s too many possible choices?  Or maybe too many things he has to keep in his mind at once.  Maybe the consequences are too harsh, or are too long-lasting.

Conversely, if a section of a game is too easy, and too uninteresting, it gives us a number of ways to analyze why.  Is it because while there are a number of choices, only one is really valid?  Maybe there needs to be more time pressure.

Another thing that it lets us look at is tension.  I’m going to define tension as “difficulty over time.”  Tension increases as a player has to make difficult decisions, and increases more if the decisions are more difficult.  Tension decreases over time.

If the tension of a game gets too high, the game can become frustrating.  If tension is too low, the game is boring.

And if tension is based on difficulty, and difficulty is based on the player, then it’s a tough job to balance the game to keep people happy.

And that’s, really, what this blog is about.

Design

Comments (0)

Permalink

What’s a game?

Well, I’m going to go with the Sid Meier quote, “a game is a series of interesting decisions.”

It’s an arbitrary choice, of course.  Any model we make about games is simply a mental model.  It can’t really be right, or wrong.  It can only be more or less useful.

I like the “decision” model for games because it seems to work the best for accurately describing games.  Let me give you a hockey example.  (I’ll use hockey examples a lot.  It’s a rich game, and far enough away from typical video game design to talk about ideas in the abstract without dealing too much with minutae of a particular genre.)

How would you define what “hockey” is?  Do you define it by the equipment?  If so, then that’s a pretty hard definition, because everything has different equipment.  Olympic hockey uses a larger rink than NHL.  Inline hockey isn’t on ice, and uses a smaller rink still.  Street hockey often doesn’t even have skates.  Both street and inline hockey can use balls instead of pucks.  Protective gear between ice hockey and inline hockey varies somewhat, and by the time you get to street hockey, there’s very little protective gear.  But these are all recognizably “hockey.”

But broomball isn’t.  It’s played on ice, and uses hard “brooms” that are basically sticks.  They even have goalies.  So on the equipment scale, it’s somewhere between street hockey and ice hockey (uses shoes like street hockey, is on ice, is on a regulation sized rink, but doesn’t use traditional sticks).  In terms of just “using the same gear as hockey,” it would seem to qualify.  But nobody would suggest that it’s hockey.  Even if you played broomball with a smaller ball (the size of a street hockey ball), and sticks that looked like regular hockey sticks, it still wouldn’t really feel like hockey.

Is it the rules?  If so, that’s a hard sell, because different places play with different rules.  International hockey is played on a larger rink, and with different icing and offsides rules.  Inline hockey generally doesn’t have icing or offsides rules, and has four players on a team instead of the usual five.  Rules change all the time - icing didn’t exist for many years, and in the last few years, the NHL has added an area behind the goal line where goalies aren’t allowed to touch the puck.

Again, at first glance, broomball has at least many of the rules as some hockey variants.  In terms of specific rules, it’s about on par with street hockey (which generally has few rules).  And the core rules (hit something into a net, past a goalie, using a stick-like thing) are the same.  But yet street hockey is hockey, while broomball isn’t.

What remains the same in all of these games is the decisions that you make, at least at a core level.  In all of these variations, you move around, manipulate a fast-moving object with a stick, and try to outmaneuver your opponents so that you can get a good shot, and hopefully score.

And that’s where broomball differs.  The use of street shoes on ice kills mobility.  The large number of people play take an emphasis off of maneuvering.  What’s left is moving a ball around, and smacking it at the goal.  Since the players are mostly static, maneuvering around a player becomes a non issue - just smack it in the general area of the goal, where you will almost certainly have someone just waiting for it.  There will be somebody from the other team there, too, but so what?  That’s pretty much the case everywhere on the rink.

Yes, different forms of hockey (ice, inline, street) have slightly different decisions to be made.  Most inline and recreational hockey doesn’t allow checking, so that’s one decision that you just can’t make.  But the core decisions that make up “playing hockey” are the same in each of them.  Most of the rules do not change the decisions that need to be made, they just weight the choices differently.

This doesn’t mean that broomball is bad.  It’s just not hockey.  And when we are looking to define games, we want a definition that can be matched to reality, and tested against existing games.

And hockey is a good litmus test for this.  A definition for hockey that explains why street hockey and Olympic or NHL hockey appear to be the same game, while broomball isn’t, is probably a pretty good definition.

And the only definition of a game that seems to do that is defining a game as the decisions that are made.

Design

Comments (0)

Permalink

What’s the point?

While I’ve recently left the game industry, I was a member of it for about 13 years.  In that time, I’ve accumulated some thoughts on games, game design, and how to go about designing games.

This is my space to record those thoughts.  It’s different from my main blog (www.wrong.net) in that the main one will focus primarily on technical content, while this one is going to focus more on the more design-y aspects of making a game.

I’m also going to focus on “games” rather than “spaces.”  In this case, I define games as the aspects of a game that are competitive - either against another player, the computer, or the designer himself.  Spaces are places where people can gather.

The two aren’t exclusive by any means - games can be used as spaces (chatting with friends while connected to a Quake server, etc.) and spaces can be used as games (playing role-playing games in an IRC channel).  I’m simply going to focus on the game-like aspects of either of these activities, but that doesn’t mean that I don’t see value in the social or space-like aspect of them.

Uncategorized

Comments (0)

Permalink