Focalization in Multi-Agent Interactive Simulations

[This is a post about game/interactive narrative design theory. If you're here for the logic and type theory, there won't be much of that in this post.]

Many of the games that interest me, including my own experiments, play with the idea of focalization in a narratology sense,* which is essentially a generalization/reformulation of the idea of "perspective" in literature (which should call to mind the terms "first/second/third person," for example). In particular, in settings where multiple agents (loosely construed as "entities in a game with somehow separable trajectories in state space") can act and interact, independently or interdependently, there is a huge space of design decisions to be made.

In this post I'm going to describe a design space for multi-agent games as context for reflecting on two projects I worked on recently, the IFComp entry Origins and the PROCJAM entry Quiescent Theater.

Focalization in Games

Quick run-down of narrative focalization (summarized from the link above, which is most of what I know about it): it refers to the variety of choices for how much the narrator of a story (and thus the reader) knows compared to the character(s). In this way, it's kind of an epistemological construct, more than "first/second/third" person's concentration on syntactic presentation. There are three points on the spectrum that Genette identifies:

  • Zero: The "omniscient" focalization where the narrator knows more than the characters.
  • Internal: The narrator knows exactly what one of the characters knows.
  • External: The narrator knows less than any of the characters; they can only describe behavioral facts.
Where literature makes more interesting use of this than cinema is that it seems to have quite a lot to do with interiority -- otherwise "zero" and "external" focalization would be identified. They're the same "camera angle," so to speak. (That is, this is a difference between cinema and literature unless you're Chuck Palahniuk, who thinks that writers should always write with external focalization.)

Where games make this more interesting than literature is that there are sort of two axes along which to consider focalization: acting and sensing. Along the sensing axis, you get basically the same range as in film or literature (depending on your medium for content delivery) -- this gives us the analog of "first person" for FPSes and "third person" for top-down strategy games. For acting (I'm deliberately avoiding the terms "controlling" and "choosing" because I see those as narratives prescribed *on top of* player inputs affecting agent actions), the default design choice made in most games is internal focalization: the player wants to know "which one is me" when there are several avatars on screen; they are asked to in some sense embody a particular in-game agent. "You play as [a certain character]" can describe these games.

But many games do use external focalization (and to a lesser extent zero). For example, most battle-simulation strategy games, such as Chess, allow the player's input to affect multiple agents(/pieces/units). Digital examples include Starcraft, which is more interesting than Chess in the sense that you can assign subsets of your units to work on multiple parts of your mission simultaneously. And there's where the computational angle appeals to me -- we have constructs and abstractions for modeling complex simultaneous action and interaction. It's called concurrency!

(As a note, my investigations into focalization were initially prompted by a talk that Robert Yang gave at Different Games 2013, which you can read a blog post about here.)

One could mix-and-match different choices of focalization on the acting and sensing axes. I could make one of those good ol' 4-quadrant squares for you, but as with most ontologies, this whole thing is a big simplification that may not prove especially useful. Suffice to say, there are interesting ways to combine the choices of "what your player can affect" and "what your player can see!"


My and Vincent Zeng's IFComp submission, Origins,  was (from my perspective) an attempt to play with focalization by showing two concurrent streams of action, wherein it appears to the player that they are controlling just one character's trajectory, but in fact the trajectories are synchronized. Some of them result in the characters converging in a final scene; some of them involve more subtle interactions-at-a-distance (as a hint - pay attention to what happens with the dog). The idea is that the default player stance of "I am this one character" should be challenged; they're really more like a drama manager coordinating two actors.

The two choices at the beginning of the game are sort of meant to be a switch to flip between "zero" and "internal" focalization. In "myopic" mode, the character you click on initially will be the only one whose "internality" (set of choices) you see, and you will be restricted to making choices from their perspective. In "omniscient" mode, you see both characters' dilemmas and can make the decision by clicking in either column.

One piece of inspiration for this piece was the game The Swapper, a platformer where you can create clones of the player character that all move in lock-step. The trick then is to choose carefully which locations you place your clones in, so that their surrounding context makes their actions meaningfully different from yours. Additionally, you can swap "consciousness" (control of the swapper gun) with any of your clones. In light of this example, the myopic mode of Origins is the one without the swapping ability. That said, it's not as meaningful of an ability in Origins, because you can't create new clones or do anything else special with "control" of the character, other than see a little more of their interior state.**

Quiescent Theater

On the opposite end of the scripted-to-simulationist spectrum of storytelling, Rob Simmons and I created Quiescent Theater, a program that procedurally generates Twine games based on action-based world models written in the linear logic programming language Celf. The actions of all the agents are pre-scripted, so player inputs cannot affect them. What the player can affect is their traversal through the space of simultaneous scenes, which must be focalized through a character. Any time the character they are "following" interacts with other characters, though, they can swap focalization to one of those other characters.

This mechanic means that any given traversal through a Quiescent Theater production kind of defies classification by Genette's original three types of focalization: it is sort of "interior", in the sense that the player senses/perceives exactly what the character they are following senses/perceives, but sort of "exterior" in the sense that no interiority is ever revealed -- in the scenes with multiple characters, in fact, it is important to keep an "exterior" perspective so that is agnostic to which of the characters the player followed to get there.

After finishing this project, I found the experience of traversing most of the stories unsatisfying in ways that I expect could be improved by allowing more exteriority; more insight into what actions are taking place alongside or simultaneous with those of the character I'm following. For instance, in the live drama Tamara that helped inspire this experiment, a gunshot or shouting in one room (scene) could be overheard by an adjacent one, and that might affect which character you choose to follow next.

A Design Space for Multi-Agent Games

An important question to ask about any game's design is "What effects do player actions have?"

In the space of games where there is more than one agent -- which is really most games, since I'm not excluding things that lack a standard notion of "agency" here -- we can refine this question to "What effects do player actions have on each agent?"

Here are some possibilities:
  • The action affects the same, single agent. This is the most common choice in digital games; you play "as" a single character for the entire game. (Even within this space, there are of course interesting questions to ask about the behavior of non-player characters.)
  • The action affects every agent in the "same" or analogous way, e.g. telling a group of Starcraft troupes to storm the enemy base, or telling the clones in The Swapper to move. (This was the choice we made in Origins.)
  • A single action affects a single agent or group of agents, but different actions affect different agents/groups, or the player can instantiate an action with an agent/group of agents of their choosing.
Within the first and last last bullet points, there's another range of possibility in the answers to the question, "While the player-affected characters are acting, what are the other agents doing?" Some possibilities include:
  • Idling or carrying on with some non-interfering autonomous action, waiting for their turn (see: the Sims iPhone game; Chess; Theatrics)
  • Carrying on with autonomous action that will potentially interfere with the player character, thus affecting the player's choices and creating tension with respect to scheduling decisions (see: Lemmings; Quiescent Theater)
  • Performing some action as an immediate reaction to whatever the player-affected character does. This direction is perhaps a generalization of the second bullet point above; agents have a script to decide what any single action will do to them, but that script need not be identical for ever character. For example, with rich character AIs, their reactions may depend on individual goals, traits, and social state (see e.g. Versu).

Concluding Thoughts (on programming languages)

Because, of course, I can't help but swing this discussion back around to tools, I have to say I'm hopeful about logic programming as a powerful vector in multi-agent simulation. Part of me wonders if the reason we've seen single-character-focused, first-person games dominate the design space is because object-oriented languages encourage it: for every entity in the game, you have to give it a set of methods describing its behavior. If you want an entity to interact with another entity, well, you have to decide which entity owns that behavior (which one is the actor, so to speak, and which is the acted-upon). That makes it a sensible design decision to introduce asymmetry in the architecture of non-player vs. player characters: the player will always be the actor and the NPCs the acted-upon.

From a logic programming perspective, everyone's state lives together in a big soup, including pieces of state that relate multiple entities, like is_mad_at(A,B). This means that the mechanics of the game can be written in a way that's completely agnostic to which character decisions are determined by a human interactor.

In the comments I'd be curious to hear from you about your favorite multi-agent game mechanics, or thoughts about tool & programming language design for multi-agent simulations.


*Not in the logic sense, the one I was initially more familiar with. Incidentally, my self-stipulated win condition for my thesis includes working out a way to include both senses of the word in a single chapter.

** V and I were initially were just undecided about which mode to publish as telling a better story -- which meant we said "hey, let's publish both and let the player decide!", which I think was in retrospect a poor choice. They are, in practice, only subtly different variations on the same branching story.


  1. Hi Chris,

    Reading your post makes me think there actually might be a connection between the two kinds of focalization!

    One thing I've wondered about your work is how you go from a linear logic proof term to story. A proof term is essentially a graph that records all the causal dependencies in all the actions that occur. But when we write a story, we write down events in a sequence (not necessarily temporal), and the reader experiences them one after another. So until I read your post, I thought of a story as a kind of linearization of a proof term.

    But reading your post makes me realize this idea is wrong, or at least too simple-minded. Your description of narrative focalization reminded me that there can (and probably should!) be events in the proof term that the narrative will not record. For example, the CLF program might have a rule that Alice will shoot Bob only if she hates him, but a story written with an external focalization will refrain from reporting Alice or Bob's mental states, leaving it to the reader to work out that Alice was angered when Bob stole her money.

    This then reminded me that when we say "variables are used once" about linear logic, we're not talking about the number of occurrences in the term, because the same variable can occur multiple times in a proof. (E.g., λx. (x,x) is a proof for A ⊸ A & A.) "Usage" actually means that when you run this program, so that in any run of a program (say in a Krivine machine), each variable appears in evaluation position at most once.

    Now, one way of thinking about proof-theoretic focalization is as a way to specify evaluation order/handle effects. If we model the abstract machine the program runs in as as a labelled transition system, by choosing different kinds of labels we can model different kinds of effects. So if we have a CLF proof term representing an event structure, then we can imagine "running" it and seeing what effects happen, by passing it to a continuation (which might perform side-effects) expecting an argument term's type.

    So here's the idea:

    1. Perhaps we can think of a narrative as the sequence of labels in a reduction sequence for a CLF proof term interacting with a continuation.

    2. Moreover, maybe different narrative focalizations correspond to different possible side effects with which to interpret the shift operators. (E.g., in a tight-third POV, only actions involving the main character are considered effectful, and all other actions are silent transitions in the LTS.)

    This is all super-speculative, but maybe these speculations are interesting to you....

    1. Interesting thoughts, Neel! I'm a bit fuzzy on the connection between proof-theoretic focalization and effect handling; can you point me to a set of inference rules explicating that idea a bit? I do like the thought of interpreting narrative focalization as a choice of which actions are considered effectful; I'd like to investigate further.

    2. I don't mean effects as in effect handling, but something a bit simpler than that. In Noam Zeilberger's thesis, he shows how we can think about focusing as a way to specify a CPS conversion, and thereby specify an evaluation order. Now, in a CPS transform of an intuitionistic language, the answer type of the continuation is parametric -- it doesn't have to be false, it can be any type you like.

      So we can choose the answer type to be (say) the type of I/O computations, and define some effects, like outputting some pieces of story. Some realizers for the logical axioms (eg, Alice shoots Bob), might have an output effect, and others (eg, changes in Alice's mental state) might not.

      So the idea is that logic programming finds a "story plan" of type X, and then evaluating it with a continuation of type X ⊸ ans will produce a story, as the output produced by evaluating the answer. (One might even think of a continuation as a model of a reader!)

      Overall, it seems like there's a lot of neat stuff in your approach, even just when thinking about the special case of story generation, rather than full-on games.

  2. I think there's an interesting temporal distortion with stories. If the audience can see or affect things, then those things have room for more fine-grained details, exploratory tinkering, and plot twists. They have less inertia than the rest of the world.

    This is a little bit counterbalanced if an interactive story is easy to replay frequently, since the things that confuse the audience on one playthrough can be justified in another.

    Meanwhile, lots of stories approach an eventually omniscient viewpoint, even if they aren't narrated that way. A player can already cheat themselves into omniscience by replaying or collaborating with other players. An author can already cheat their way around non-omniscent focalization by inserting more scenes that reveal all the information they want to reveal.

    It would be pretty cool to make a drama manager that starts with a strict simulation, but then inserts those workaround scenes to help the player understand what they've missed. This could be more gentle than immersion-breaking replays, while at the same time keeping the player busy enough to have ultimately just as much inertia as the rest of the world. ;)

    The technicality of tailoring the story for the player seems antithetical to simulation, but I bet it'd actually make simulations more useful for storytelling.

    I don't have as much to say on the "multi-agent" topic in particular, but I'm a fan! I've long had a casual intention to write a story with a body-swapping mechanic, but it would be rather tough to keep that story's plot safe from combinatorial explosion... without a principled simulation, that is. :)

    In case this posts as anonymous, I'm Ross Angle ("rocketnia" on WordPress and Twitter).

  3. Thanks for posting this! I'm very interested to read about these projects.

    The comments about multiple agents reminded me a bit of the structure of this past comp's Fifteen Minutes, but in an inverted form, since the behavior of other time-traveling versions of yourself exists as a significant constraint on what the player is allowed to do.

    My current thinking on the "what do other agents do?" problem: if what you want is something that runs as a simulation but really presents a story, you have a couple of options: a) make scripted story aspects that are able to override part or all of the simulation at need (which is what we did for Blood & Laurels), or b) consciously make the other agents be driven by dramatic concerns as well as personal motives, and who are able to act as antagonists in the sense that's meant in tabletop storygaming (Polaris is a great example for this). Which is not say: not necessarily *the villain*, but a character responsible for complicating the plot for the protagonist. Sometimes this can take the form of directly trying to foil their wishes, but often it means adding some undesired consequence to an action they took.


Post a Comment

Popular posts from this blog

Reading academic papers while having ADHD

Using Twine for Games Research (Part II)

Using Twine for Games Research (Part III)