Representing State

When you play a game, you manipulate game objects using various actions, all of which are defined in the game’s rules. In this post, we’ll look at game objects and how to represent their state.

To make this descriptive effort easier, I’m going use, as a reference point, a generic SRPG or character-based turn-based strategy game.

A character in our notional SRPG is a game object: Just some thing we hang state off of that the game’s rules bring to life. I call the smallest piece of state on a game object a dimension. Dimensions can be a position in space, a maximum amount of HP, current amounts of HP or some other resource, a list of status effects currently afflicting (or aiding) this object, etc. Beyond those more obvious cases, a character also has a series of dimensions relating to what they can do–like their abilities, magic they know, and reagents they are carrying to be used in that magic.

Some dimensions are straightforward in how you represent them. HP is clearly best represented as a number. But you can represent other kinds of dimensions in different ways. You could look at status effects as each having their own dimension on the character they effect which can either have a value of “yes” or “no”. Perhaps a poison effect has some additional dimensions of its own, like how many turns it will last and how much damage it does per turn.

As the poison example illustrates, dimensions can also have dimensions of their own. A character’s position in space is articulated in two or three dimensions, each of which can vary independently.

Let’s dwell a while longer on space. Space is very interesting because it’s a pre-established (outside of the game design) relationship between two or more dimensions. Usually you don’t have this kind of thing going on with game objects’ dimensions. HP doesn’t have any clear connection with another dimension on a character. It’s just a singular number that is typically separately modified by game rules. Space is way more interesting than that, because you have two or three dimensions which have a built-in concept of adjacency. You can define adjacency in a number of ways, but you know from the very concept of space that you’re going to have consistent adjacency across the whole space. You can even choose to define adjacency as totally fluid; you can see this in Paradox Interactive’s grand strategy titles, which feature a map of provinces which have odd shapes and all different numbers of adjacencies to other provinces.

Adjacency is a simple way of saying “given one position, what other positions are one step away?” But you also have this built into singular numerical dimensions, like HP. 6 HP is one step away from 5 HP. Arithmetic operations provide us with a kind of adjacency over numbers. We use this all time in damage and healing amounts for different character abilities, just as we have ranges on attack and movement.

But what about status effects? They seem different. Since they’re just a bunch of separate labels, the only concept of adjacency they may possess is through turning them on and off. So you get a lot of variety out of space, a lot less out of HP, and simpler still are status effect which seem to have almost nothing to offer us.

Though the game’s rules tie all dimensions of game objects together in a variety of ways that end up being what is so spellbinding about games, some kinds of dimensions need more from the rules than others. The meaning of a status effect lives entirely in the realm of the rest of the game’s rules. Space and numerical dimensions have some room for different magnitudes of changes by virtue of existing mathematical relations. status effects have nothing of the sort beyond the most basic “on” and “off” transitions. The game rules, then, define all the meaningful relationships between the status effects. Being frozen in place ties into the character’s ability to act but also makes fire attacks potentially melt the frozen character and free them. Perhaps against a neutral-status character a fire attack begins burning them, instead. This kind of dynamic response isn’t built into status effects as a concept, it’s articulated entirely through game rules that are defined outside of state.

This property means status effects are the most basic kind of dimension a game can have. The simplest kind of state a game object can have merely has those same two values a typical status effect has: on or off. You can’t get any simpler, because with only one possible value, the dimension would be incapable of varying and would cease to be state, it would be some inherent unchanging property codified in the game rules.

Numerical dimensions can be defined in terms of simple dimensions by using several simple dimensions together to represent a binary number. So “on” + “off” + “on” would represent 5. This is not practical, but it shows that all state is an elaboration on the simple dimension combined in some way. Space is just two or three numerical dimensions taken together as one dimension. There’s a natural complexity progression from simple dimension to numerical dimension to spatial dimension.

We already knew that we could represent games in computer code, so what’s the point of this exercise? It’s an introduction to a simple way to represent state in game: game objects, which are logical groupings of some number of dimensions. This terminology and way of breaking down state helps us to represent games concretely and precisely, and gets us one small step towards having an objective and concise representation of game systems that we can reproducibly analyze. With such an analysis we can prove that a game has certain properties, and then we can talk about the dynamics of games systems in a precise way through talking about how these properties interact. From there, we have a stable foundation for having substantial knowledge about what designed game systems do.

In summary:

  • Game state consists of game objects which consist of dimensions.
  • The simplest dimension is binary: on or off. Like a status effect in an RPG.
  • Numerical dimensions can be derived from binary dimensions. We do this for the convenience of using mathematical relationships to quickly articulate a wider variety of state changes. The simplest is adjacency–better known as adding or subtracting 1. Through applying adjacency multiple times in various patterns, familiar mathematical operations like multiplication and division happen.
  • We can group dimensions together, creating space. There are then more complex adjacency rules relating the dimensions that comprise space.
Written on March 20, 2017
Join the dinofarm discord to chat with me and others about strategy game design!