Skip to main content

Logic Programming for Interactive Fiction

As a teaser-trailer to the ideas I have been long overdue to write up, allow me to play some silly games with words. All claims herein are nontechnical and unsubstantiated.

PL theorists are fond of the snowclone X-as-Y, "props-as-types" and "proofs-as-programs" being the pervasive example in functional programming. When we similarly try to explain logic programming logically, what comes out is more like "props as programs" and "proofs as traces". Put another way, in functional progamming, computation is proof reduction while in logic programming, computation is proof search.

So, then, what is a game? (I mean in the sense of "something humans play for fun," and specifically "as a piece of software", not the game-theory sense.*) At a rough gloss, a game is an interactive program. An execution of a game alternates computation and accepting human input. Interactive fiction is a minimal distillation of the idea (in that it mostly separates itself from rendering concerns; writing IF is almost entirely writing game mechanics).

So to reiterate, in a logic programming setting, computation is proof search. Hypothesis: interactive computation -- that is, a game -- is interactive proof search, or ITP). (Ever heard someone marvel at how using Coq feels like playing a video game?) Allowable actions for a user to take turn into inference rules (at the object level, so horn clauses), and the game can treat this as a suggestion for proof search, after which point it may forward-chain to arrive at the next state of the game. Specifically, some flavor of linear logic programming seems natural to meet the demands of encoding state transitions.

What I would like to post about next is a few of the low-level ideas that can potentially lend service to this overarching motivation.

---

*Or do I? To throw yet another analogy-turned-correspondence into the mix, it turns out that you can give a game semantics to proof search, giving way to types-as-games and proofs-as-strategies -- not all too different from what I am proposing.

Comments

  1. Interesting. I recently stumbled on the IF language Inform 7, and I was surprised by the declarative, logic programming side to it. But, it handles state change in ad-hoc ways, and I wondered whether some kind of linear logic could remedy this.

    Sounds like you've gone quite a bit further than just wondering. Any chance of hearing about the low-level ideas?

    ReplyDelete

Post a Comment

Popular posts from this blog

Using Twine for Games Research (Part II)

This preliminary discussion introduced my thoughts on using Twine as a tool for creating prototypes for games research. I'll start with documenting my first case study: a hack-and-slash RPG-like setting where the player character has a record of attributes ("stats") that evolve through actions that turn certain resources (money, health, items) into others. I've selected this hack-and-slash example because it falls outside the canonical "branching story" domain thought to be Twine's primary use case, but it is not too much trickier to implement. It relies crucially on the management of state in ways that simple branching stories would not, but it does so in a fairly straightforward way.

If all goes well, this post may also serve as a tutorial on the "basics" of Twine (links + variables + expressions). In particular, I'll be using Twine 2/Harlowe, and I haven't seen many tutorials for this new version published yet.

To me, the main "…

Using Twine for Games Research (Part III)

Where we last left off, I described Twine's basic capabilities and illustrated how to use them in Twine 2 by way of a tiny hack-and-slash RPG mechanic. You can play the result, and you should also be able to download that HTML file and use Twine 2's "import file" mechanism to load the editable source code/passage layout.

Notice that, in terms of game design, it's not much more sophisticated than a slot machine: the only interesting decision we've incorporated is for the player to determine when to stop pushing her luck with repeated adventures and go home with the current spoils.

What makes this type of RPG strategy more interesting to me is the sorts of decisions that can have longer-term effects, the ones where you spend an accumulation of resources on one of several things that might have a substantial payoff down the road. In a more character-based setting, this could be something like increasing skill levels or adding personality traits.

Often, the game-…

Why I don't like the term "AI"

Content note: I replicate some ableist language in this post for the sake of calling it out as ableist.

In games research, some people take pains to distinguish artificial intelligence from computational intelligence (Wikipedia summary), with the primary issue being that AI cares more about replicating human behavior, while CI is "human-behavior-inspired" approaches to solving concrete problems. I don't strongly identify with one of these sub-areas more than the other; the extent to which I hold an opinion is mainly that I find the distinction a bit silly, given that the practical effects seem mainly to be that there are two conferences (CIG and AIIDE) that attract the same people, and a journal (TCIAIG - Transactions on Computational Intelligence and Artificial Intelligence in Games) that seems to resolve the problem by replacing instances of "AI" with "CI/AI."

I have a vague, un-citeable memory of hearing another argument from people who dislike the…