You are here

Dev Logbook

On implementing a theory of the mind (or: What took you so long?)

AHasvers's picture
Submitted by AHasvers on Mon, 01/04/2016 - 01:49

And a happy new year!

So, why haven't I posted anything since time immemorial? (except for a silly joke)

The reason is simple: on one hand, lots of real work, on the other hand, improving the engine became a lot like work. But not for the reasons you would expect: it was not a problem of it being tedious. Well, sure, some if was and that didn't help.

The real problem though, is that I stumbled into an actual CS research problem. See, what I was trying to do was supposed to be simple: characters have either positive, neutral or negative belief about various statements, and there are logical links that are activated by certain statements and reinforce or oppose other statements. Characters come with only a few fundamental "biases" i.e. preexisting beliefs; all their other positions are simply derived logically from those few axioms. Explore the beliefs of others until you find their biases, and find counter-arguments to the biases you don't like - and BAM, you've rhetoricized the other characters into agreeing with you.

That was the plan.

But I didn't want it to be a perfect information game. I wanted there to be a sort of fog of war. The weak kind of uncertainty is that characters don't have all their beliefs in mind all the time, and they can ignore the existence of certain beliefs and links.

The strong kind of uncertainty is that you don't know exactly how the others feel about every single statement, you infer it from what they say, and from how they react to what you said on a scale of agreement-disagreement. That's extremely unwieldy if the player has to keep track of all such details, so my plan was to give them an automatically-computed map of the estimated beliefs and biases of other characters -- that could be more or less accurate, depending on the skill of the PC for perceptiveness and other characters for deception.

That sounds exciting, huh? Well it does to me. But that's where it gets bad.

First, I should mention: what's the point of having and stating neutral beliefs at all? Well, let's say you voice a noncommittal statement, like "Maybe it was the butler all along, maybe not". It can be a first step in making a link such as "Maybe the butler did it, and in that case, the knife must be in the pantry". Now that you've said that, you *know* that the other characters know about it, and therefore, if they do have a belief about the butler, you are sure that they will take it into account when they think about the location of the knife. That's how you can convince them of something that you're not sure yourself.

That was neutral beliefs interacting with "weak" uncertainty. But how do they interact with "strong" uncertainty? You are noncommittal, so you cannot deduce whether they agree or disagree with you - unless they actually voice their opinion (which they could do to reclaim possession of the topic for scoring purposes, but that's another topic). So you now have a statement where you have a large uncertainty on what someone else believes. Okay, not so bad, is it?

It is bad.
Because that uncertainty propagates. It means my characters are not doing logic, but Bayesian inference. Let's say someone disagrees with the fact that the knife might be in the pantry, even though you pointed out the link to the butler. Does it mean that they are biased against the knife being in the pantry (because they don't want you to go there perhaps?), or against the butler being the culprit? If you knew their positions on everything else in the world, you might be able to decide; as such, knowing where they are biases lay becomes a parametric inference problem where you are trying to find the distribution of parameters (biases) that best fit the data of what you can infer from the others' statements and agreement to yours, while respecting certain constraints (as few biases as possible, aka Occam's razor). That's not quite black magic, there are lots of good methods for that sort of things in machine intelligence textbooks, but that's another level of complexity entirely - and it's never been piled on top of the sort of logic I'm using.

So, around last September, I finally got the rest of the interaction model to work: you say something, they (maybe mis-) interpret what you say, they react to their interpretation, you (maybe mis-) perceive their reaction, and you infer what they think about what you said. That was already tricky.

But I didn't go into the whole uncertainty thing, only used very simple estimates with no probabilistic computation at all. And it's come back to bite me by creating all sorts of exotic bugs leading to the PC completely misrepresenting the beliefs of other characters for no good reason. especially complicated by feedback loops on the network of beliefs.

And here I am. Today, I have had to decide: do I want to make a game, or a state-of-the-art AI model of argumentative interaction? The answer was surprisingly hard to find. It's not your typical case of feature creep because, well, the game was meant to research the mechanics almost as much as the reverse. But okay, I need to make a game more than I need to make AI. Which means I'll scrap the strong uncertainty for now, and pray it doesn't kill the vision entirely.

That was the story, lasses and lads. Welcome to 2016.

New Business Model

AHasvers's picture
Submitted by AHasvers on Sun, 12/27/2015 - 05:12

Yes, we are alive (one never wearies of the royal we). An important message today, so that the year does not end without exciting news from Lilavati.

As a reaction to recent trends in videogame development and marketing, I have been reconsidering my options for our business model. Here are my ideas so far:

  • The macrotransaction: You pay me 40k a year + benefits, and I will make a whole new game just for you.
  • The megatransaction: You give me a home and food, adopt me legally, and make me sole heir to your earthly possessions, and I will conceive a whole new artform dedicated to your undying glory.
  • The Omegatransaction: You build me a civilization of alabaster temples and eternal flames, drenched in the blood of slaves and conquered nations, and I will code self-replicating nanobots and send them across space to arrange the furthest galaxies into q-gravitational parallel processors, software writ in exotic rules upon the hardware of physics itself, so that the whole universe becomes the chessboard for an Absolute Game of Life, a slowed-down simulation of itself starting back from the Big Bang and following every single particle in digital glory, identical to its former self except for a very single detail: a new costume pack is now available for your characters in our latest expansion!

Narrative Gameplay: Why everyone is wrong (except you?)

AHasvers's picture
Submitted by AHasvers on Sat, 01/31/2015 - 02:16

The pitch: In my humble* opinion, almost everything you have ever read about how to do narrative in games is either far too optimistic about emergence, or far too pessimistic/conservative about what games can be. Narrative gameplay - playing with the story, altering it beyond scripted choices - is a very real possibility, but I'm quite sure it will spawn neither from the sandboxes, nor from the cinematic storytellers. In this post you will find, if not the solution, at least a strong conjecture on where to look for it.

* Citation needed.

NB: This post is rather irrelevant to Lilavati's current project, but it's been in my head for a long time and it will definitely figure into Project N+1 or N+2. Though I would not at all be unhappy if someone else came to the same conclusions in the meantime, and did something about it.

1/4) The emergence buzzword

Having a dynamic narrative sounds great, but what people usually mean by that is that they will make a really detailed world with thousands of nifty little things, and somehow a great story will emerge from it.

The thing is, making a story is not so different from making a sentence: it requires grammar, meaning, relevance to context and (if you want a good story) stylistic flair. You know how good AIs are at making sentences after sixty years of research. That's pretty much how I expect things to go for emergent stories too.

When it comes to narrative, I put absolutely no faith into what I'd call "strong emergentism": you cannot just cobble up dozens of arbitrary rules (say, AI agents with needs and schedules), fiddle with parameters and expect something dramatic to arise out of it spontaneously. In real (physical or biological) complex systems, the range of parameters for which you get interesting behavior is usually extremely limited* and it's very unlikely that we'll get there without either a good theory or billions of years of trial-and-error.

What you can get out of a metric ton of microrules is a reactive playground, where the player can do the work of taking some of what they see and turning it into a story. At best, something like Dwarf Fortress. It can create great material for a Let's Play, but it's not what interests me most - I like reading someone else's story for the added value that their effort has put into it, and I crave meaning more than quirky random happenings.**

* Broadly speaking, that's called a critical point. As in, you have to find a single point in an infinite space and stay more or less on top of it (life is good at doing that).

** That's because I'm a narrativist and not a simulationist - it's great if you are the latter though, as you are more likely to be satisfied by currently existing sandbox games.

2/4) One solution, Part 1: Theory

So instead of trying to follow the example of natural language processing, my inpiration is how physics engines and physical interaction have grown in games:

  • At the most basic level, you have something like a QTE: just do what the game tells you to do and advance to the next step. Narratively speaking, that's scripted FPSes and quests in your typical RPG - a trajectory where your every step is hardcoded and you just have to pass a true/false check to go to the next one.
  • Then you have Pong: every key press moves a cursor along a line, and if it's at the right position when the ball arrives, something different happens. Narratively, that's reputation/karma systems where your actions change your position on a line between Goode and Badde. Although in those games you can't even see in advance when the ball is coming, i.e. when your position on the line will be tested by an event, so you cannot plan which narrative choices to take, just accumulate brownie points on principle - let's call that Blind Pong.
  • Eventually we evolved platform games: you know where you want to go, you know which key to press to run and which one to jump and how high that will take you. The designer does not spell out your every move, she just places the platforms and expects you to figure how to get there.

The latter is precisely the step I want game narrative to take now: written story bits as platforms, and a very limited set of actions that have predictable, repeatable, rule-like effects, that you must compose freely to make your own path toward the objective.

At this stage, the key ideas are:

1) You hardcode states, not trajectories: the platform knows only where it stands, not how you got there. On the other hand, the relative positions of the platforms create a macro-path, defining the global boundaries of where you can go.

2) The actions move you in story space - the space in which every location is a different narrative state. Story space is not the complete state of the universe: most of what happens in the world is irrelevant to the story, so relevant actions should not be lost in a sea of variables and complex AI patterns*.

In other words: the player must know which of their (and others') actions will advance the story. If those are defined systematically, instead of being arbitrarily decided by a writer, you won't need to acknowledge them all with scripted content. This already exists in a primitive form in many games: when you kill a boss, you know that you have progressed in the story; there is no need for a cutscene to let you know what you have just achieved - in that case, the very act of killing carries its own narrative meaning. Another example is running away in survival-horror games: you know you succeeded if you escaped from the monster, the gameplay and narrative goals coincide perfectly. Scripting becomes important only when "jumping there" or "killing this one guy" must carry a different meaning from jumping anywhere else or killing any other guy,

* If you put in too many variables, you create that "noisy" situation where the player is never able to tell whether something is part of the story or some random happening, and they can at best fish out a collection of "interesting bits" and story snapshots (suddenly Jane the sniper did something cool and worthy of being related) rather than a narrative.

3/4) One solution, Part 2: A concrete example

This is all good, but quite abstract. The thing is, it is surprisingly simple to do for real. Off the top of my head, here's a simple implementation idea or two.

First you must have a narrative goal: any story is centered around a conflict. Other characters should solve their conflicts automatically if they can*. If the game exists, it's because no one has the means to solve the central problem. No one but the player, of course.

That's where the gameplay comes in. For instance, you could be given a set of physical actions (moving around, jumping) but a single narratively relevant action: killing people. Let's also say that:

  • characters are tied by relationships that are positive or negative,
  • conflicts happen when two people with a positive relationship have a different opinion of a third party (say the daughter, a father, and the daughter's lover, who is disliked by the father),
  • and killing a character voids all relationships that involve them.

Now we have a simple problem: remove enough people, in the right order, to solve all conflicts. Sure, this is extremely primitive (plus, morally wrong), but it captures the main ideas: you have actions that change the narrative state according to systematic rules, which you can use to make informed decisions rather than blind choices. You may add some imperfect information on the relationships to spice things up, but not so much that it reverts to choosing at random and praying, like in so-called "choices and consequences" games.

A more elaborate version could be the analogue of a puzzle with balls that roll down slopes unless their path is blocked: the other characters will act to solve conflicts within their means, go toward the place they want to be, provided you remove some initial block (deliberately, or as a side-effect of some other action). Whether that place is where you want them to be is another problem, and the essence of the gameplay is using some of them to block some others and herd them toward the right place.

Both of those examples may look like puzzles (with a single correct solution) rather than systems allowing for full creativity, but the mechanics they involve can serve as the basis for a system, using the platform metaphor: rather than a single way to solve the conflict, you put some conditional states as intermediate goals and let the player invent a way to reach them. Each of these states then puts new places within your reach (a new character arrives, or some external event happens), and the general narrative moves along in the direction implied by them.

* Is there really no postal service in any of those games where people wait for random strangers to come by and deliver their love letter?

4/4) To infinity and beyond

Once games started having physics engines, they all had a common basis to build on: picking up a new game, you'd know you could run, jump, destroy blocks, push things, and so on. This opened up lots of more sophisticated possibilities, and a whole new job appeared: level designer. Suddenly, you were not a lone programmer coding every single detail of the player's interaction with the game world. You shared an easel and a set of brushes and could compose bits and pieces of the world to make it interesting, while the player would explore it using learnable and transferable mechanics.

If narrative gameplay took the same path as physical gameplay, then the job of scripting an entire game's story exhaustively would likely disappear (at least in certain genres). You would instead have drama designers who would arrange bits of conflict into an explorable landscape with a global goal, and let the player figure how to deal with them using a common set of rules.

And I think that would be pretty nifty, overall.

Origins and Influences

AHasvers's picture
Submitted by AHasvers on Sat, 01/03/2015 - 07:13
As a first non-trivial devlog, it feels appropriate to share some thoughts on the main influences behind this site and our projects.

What's in a Rose

Līlāvatī means the Playful One.

As Wikipedia would tell you, it is the name of a mathematical treatise written nine centuries ago in Karnataka. It was authored by a certain Prof. Bhāskara, ostensibly for the benefit of his daughter Līlāvatī, who was adequately named, and seemed to enjoy arithmetic and geometric games (as long as they were framed as stories about monkeys).

This makes it one of the few historical examples of decent math education. But the treatise is also a case of gaming, scientific knowledge, and literary qualities meeting in a single work - a work that is played and studied at the same time.

And of course, the name might evoke another playful young Lady, who enjoys puzzling mortals and trifling with the all-too-serious laws of the material world, and who happens to be the protagonist of a certain project in active development.

Ludus Magistri

Hermann Hesse's novel Glass Bead Game tells of a game that conjures discourse, debate and poetry out of beads on a board. A game that one can use to ponder a theory, draw a solitary meditation, or humiliate an adversary in a public display. Something like philosophy-as-chess, or a scientific I Ching.

If the idea of such a game arouses nothing in you, you might want to consult a shaman about the fact that you have no soul. In any case, Lilavati was conceived in the steamy aftermath of this literary encounter, and while we're not actually trying to replicate this game, just borrowing a beautiful metaphor, I do feel that our games have some kinship with real attempts at designing a Glass Bead Game.

Fae Fictis

While I might have been throwing around the literary game label for our projects, I claim no relevance to literary critcism or its enclave in game scholarship. Here are however a couple of lineages to which I hope Lilavati shall belong:

  • Interactive Fiction: Of all the game narratives that I have experienced, the most enlightening or mindblowing, the most different from books and film, the most satisfyingly gamelike I found in games made entirely of text. Many of them not even pretentious about it.
    (Then again, it may help that narrative is not an arthouse luxury in IF, it is the medium itself. Plus, assembling clever people who like stories and puzzle solving, and asking them to solve the puzzle of designing stories for a new artform? Sounds like a plan.)
  • Dialogue as a genre in philosophical and scientific writing, for proving that deep insight - even legit scholarship - can be framed into a conversation and made entertaining. Especially the Dialogues of the Dead subgenre, because what is better than a verbal melee of historical celebrities?
  • The Scholastic method and especially Disputatio, the scholastic art of learning through debate. Most important is the fact that, whatever your position, you must always defend the opposite - which is great practice for designing a discourse game, if you do not want to end up with a one-sided Author Tract.
  • And, to some extent, Rationalist Fiction. While it is fair to have reservations on the genre's codifier (author of the previous link) and its assorted community, I can only empathize with the aim of depicting characters acting truly intelligently, i.e. demonstrating abilities that the audience can actually reproduce and learn from, rather than plot-driven mental superpowers. This is, in fact, what makes some literary genres so game-like: in a good detective story, there is an element of play because readers have the possibility of finding the answer themselves, rather than wait for the detective to come up with a solution. It is a sad fact that very few games have a narrative even halfway as game-like - and cognitively challenging - as an Agatha Christie short story.

Proud to announce birth of little Līlāvatī

AHasvers's picture
Submitted by AHasvers on Fri, 01/02/2015 - 12:43

And so it begins, in sweat and tears and endless fiddling with internal organs.

Welcome to all the ghosts and GoogleBots who have followed a star from hyperlink to hyperlink to deliver presents of bandwidth use and search engine ranking.

Welcome, more probably, to visitors from the future who have enough free time to spend it digging through blog archives, hoping perhaps to find a relic of the golden time when Līlāvatī was still human-sized rather than a Microsony-owned multi-billion juggernaut.

Welcome indeed, sit here near the fire, and let us watch History as it is born. Maybe.

PS: We have a Twitter account. It is currently barren, but we have good hope that it shan't stay so:

Subscribe to Dev Logbook