Rule-Based Programming in IF

10 views
Skip to first unread message

Andrew Plotkin

unread,
May 5, 2009, 12:36:10 AM5/5/09
to
This past weekend I gave a talk on Inform 7, and more generally on the
rule programming model, at an SF convention in Michigan.

The slides and (approximately) the text are now up on my web site:

<http://eblong.com/zarf/essays/rule-based-if/index.html>

The description of I7's rule model, and why it exists, will be
familiar to anybody who's been hanging around RAIF for the past few
years. I then go on to talk about my crazy ideas for a *completely*
rule-based language; those aren't new either, but I don't expect that
everybody has been tracking my sporadic newsgroup ramblings on the
subject.

The talk went nicely, in case you were wondering. About eight or ten
people showed up, which is pretty good for a programming lecture at
10 AM on a Sunday.

--Z

--
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
*

S. John Ross

unread,
May 5, 2009, 2:14:40 AM5/5/09
to

> About eight or ten
> people showed up, which is pretty good for a programming lecture at
> 10 AM on a Sunday.

Hell yeah. Congrats on that. Sunday-morning panels are mainly for
people who are still awake, bleary and sticky from Saturday's into-the-
night booze-and-sex revels with people in Klingon and/or squirrel
costumes.

Not that I do that anymore, mind you. These days Sunday morning panels
are for sleeping through until one of the con handlers come knocking
angrily on the hotel door wanting to know if I intend to earn my badge
or just pay for it.

(Speaking of which: anyone in Dallas, come see me at A-Kon, and if we
can find 10 people to talk about IF at ANY hour of the day I'll be
shocked, but I'm game for trying ...)

(and I still don't have my itinerary, so for all I know I may be
expected to ... I DID mention ToaSK in my guest bio ...)

Victor Gijsbers

unread,
May 5, 2009, 4:37:38 AM5/5/09
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Interesting talk; thanks for putting that up.

Also, getting cursed by the Slumbering God for the thousandth time bites.

Regards,
Victor

P. S.

"So you can't afford to think about the interactions between this tweak
and every other tweak in the game. That's N-squared interactions..."

Only N, I believe.

(Which admittedly does mean that you've look at order N-squared
interactions by the end of the design process.)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkn/+tIACgkQoiOrMwvIZLx8GwCggQSQ4i/uIA1vqHQWXTHgZmFL
Y8EAn2Kbynn9HTNSR9A6Lulh8bBwsoiY
=l34y
-----END PGP SIGNATURE-----

David Fisher

unread,
May 5, 2009, 9:02:46 AM5/5/09
to
"Andrew Plotkin" <erky...@eblong.com> wrote in message
news:gtofnp$a53$1...@reader1.panix.com...

> This past weekend I gave a talk on Inform 7, and more generally on the
> rule programming model, at an SF convention in Michigan.
>
> The slides and (approximately) the text are now up on my web site:
>
> <http://eblong.com/zarf/essays/rule-based-if/index.html>

Thanks for that ... you explained the issues very clearly (sounds like the
audience
wasn't necessarily familiar with IF).

The CYOA style quotes at the bottom of the slides were cute, too.

A thought about standard library rules, extension rules and game rules all
interacting:

Unless there is a universal world model (bad idea for various reasons), I
think it will always be necessary to resolve issues manually (your "throw an
error and let the author fix it" option). A worse problem is when the
compiler doesn't detect any conflict, but the world models of various
extensions & your game are subtly different ... there is an implicit
precedence between all of the rules, but the result is not what the author
wanted (if he knew about it).

This whole thing is a similar problem to merging ontologies ... not sure if
that's a helpful thing to know, though.

David Fisher


Andrew Plotkin

unread,
May 5, 2009, 10:24:54 AM5/5/09
to
Here, Victor Gijsbers <vic...@lilith.gotdns.org> wrote:
>
> "So you can't afford to think about the interactions between this tweak
> and every other tweak in the game. That's N-squared interactions..."
>
> Only N, I believe.
>
> (Which admittedly does mean that you've look at order N-squared
> interactions by the end of the design process.)

Yes, that's what I meant -- N-squared in the process of writing the
game.

Andrew Plotkin

unread,
May 5, 2009, 10:41:04 AM5/5/09
to
Here, David Fisher <david...@australiaonline.net.au> wrote:
>
> Thanks for that ... you explained the issues very clearly (sounds like the
> audience wasn't necessarily familiar with IF).

Correct.



> The CYOA style quotes at the bottom of the slides were cute, too.

I look to keep the audience amused. :) Or more likely they didn't have
time to follow that thread -- it was exactly 50 minutes of talk
(leaving room for 10 minutes of questions), but only because I talked
too fast.

> A thought about standard library rules, extension rules and game rules all
> interacting:
>
> Unless there is a universal world model

Even if!

> I think it will always be necessary to resolve issues manually (your
> "throw an error and let the author fix it" option).

The whole rule-precedence and group-precedence idea at the end was
implicitly branching off that last option. (I can make that clearer.)

Really, I'd like the compiler to make *some* assumptions beyond strict
logical implication. Otherwise conflicts are just too common. But this
is up in the realm of guesswork.

> A worse problem is when the compiler doesn't detect any conflict,
> but the world models of various extensions & your game are subtly
> different ... there is an implicit precedence between all of the
> rules, but the result is not what the author wanted (if he knew
> about it).

This is where structured compiler output, as in I7's rules index, is a
lifesaver.

I think that differences in *world model* will fall into the realm of
semantic conflicts, not rule conflicts. That is, the extension offers
you some code (functions/rulebooks/etc) and you simply use them in a
way that the extension doesn't support. Or two extensions try to use a
common facility (perhaps a third extension) in conflicting ways.
Precedence doesn't fix that.

My archetypical notion of this failure is iteration. You have some way
to iterate through containers. You have some way to iterate through
supporters. Say you make a container-supporter. What does it mean to
iterate through that? That's not a rule-ordering problem; you
genuinely have to invent some solution.

(Never mind what it should be; I'm illustrating the failure mode.)

On the other hand, it would be nice if this failure was *detected* by
the compiler as a rule conflict.

> This whole thing is a similar problem to merging ontologies ... not
> sure if that's a helpful thing to know, though.

I hadn't thought about it that way, but it makes sense.

David C.

unread,
May 5, 2009, 12:15:42 PM5/5/09
to
On May 4, 11:36 pm, Andrew Plotkin <erkyr...@eblong.com> wrote:
> This past weekend I gave a talk on Inform 7, and more generally on the
> rule programming model, at an SF convention in Michigan.
>
> The slides and (approximately) the text are now up on my web site:
>
> <http://eblong.com/zarf/essays/rule-based-if/index.html>
>
> The description of I7's rule model, and why it exists, will be
> familiar to anybody who's been hanging around RAIF for the past few
> years. I then go on to talk about my crazy ideas for a *completely*
> rule-based language; those aren't new either, but I don't expect that
> everybody has been tracking my sporadic newsgroup ramblings on the
> subject.
>
> The talk went nicely, in case you were wondering. About eight or ten
> people showed up, which is pretty good for a programming lecture at
> 10 AM on a Sunday.

I don't claim anything near understanding of multi-dimensional
databases, but I just have this "feeling" that the people that write
rules for them solve some of the same problems you mention in this
presentation. The problem is that most MDDB results are numerical
results based on mathematical formulas and have default values like
zero or null. But I do know that the underlying MDDB mechanisms could
help solve the issue of “fix this group of output based on these
rules”.

Is it possible that your IF rules language also needs a querying
language? You spent a lot of time talking about an atom, but I’m not
sure you’ve spent a similar amount of time on the value of querying
the world model. When querying the world model, you’re not necessarily
looking for a single data point, but you may potentially be looking
for hundreds or thousands of data points and you want to force
different results for those data points. This could help resolve
problems with the standard responses we all want fine-grained control
over.

Respond with "You hear a grue chew its toes off....you think."
When Grue is present AND Grue has toes AND Time of Day is Dusk AND
Sally is Angry AND Bob is Hungry AND Dave is Sleeping.

I’m getting _way_ ahead of myself here, but those are my thoughts.

David C.

Andrew Plotkin

unread,
May 5, 2009, 12:42:35 PM5/5/09
to
Here, David C. <david.c...@gmail.com> wrote:
> On May 4, 11:36�pm, Andrew Plotkin <erkyr...@eblong.com> wrote:
> > This past weekend I gave a talk on Inform 7, and more generally on the
> > rule programming model, at an SF convention in Michigan.
> >
> > The slides and (approximately) the text are now up on my web site:
> >
> > <http://eblong.com/zarf/essays/rule-based-if/index.html>
> >
> > The description of I7's rule model, and why it exists, will be
> > familiar to anybody who's been hanging around RAIF for the past few
> > years. I then go on to talk about my crazy ideas for a *completely*
> > rule-based language; those aren't new either, but I don't expect that
> > everybody has been tracking my sporadic newsgroup ramblings on the
> > subject.
> >
> > The talk went nicely, in case you were wondering. About eight or ten
> > people showed up, which is pretty good for a programming lecture at
> > 10 AM on a Sunday.
>
> I don't claim anything near understanding of multi-dimensional
> databases, but I just have this "feeling" that the people that write
> rules for them solve some of the same problems you mention in this
> presentation.

You're probably right, but I know less about databases than you do.

> Is it possible that your IF rules language also needs a querying

> language? You spent a lot of time talking about an atom, but I?m not
> sure you?ve spent a similar amount of time on the value of querying
> the world model.

I've been assuming that you query the world model by testing
relations (as in I7), and relations are expressed as atoms.

Group results, and group operations, are something I haven't thought
about -- except for handwaving about "iterators". Obviously, I think
I7's group operations are keener than kittens, and I want something
like that; but that doesn't look like a solution to the problem I
have, so I'm not getting into it for now.

> Respond with "You hear a grue chew its toes off....you think."
> When Grue is present AND Grue has toes AND Time of Day is Dusk AND
> Sally is Angry AND Bob is Hungry AND Dave is Sleeping.

That's a simple condition, and I've already got those in the system.

Ron Newcomb

unread,
May 5, 2009, 2:43:38 PM5/5/09
to

Interesting read.

On May 5, 7:41 am, Andrew Plotkin <erkyr...@eblong.com> wrote:
> Really, I'd like the compiler to make *some* assumptions beyond strict
> logical implication. Otherwise conflicts are just too common. But this
> is up in the realm of guesswork.

I would say "up in the realm of heuristics". The H-word echoed loudly
in my skull while I was in the "trouble spots" section of the talk.
For example, contradictions may poop on a compiler, but if we've the
case where 2 rules say Yes and 1 rule says No, heuristics says "no
problem -- the odd-man-out is outvoted, and moreover, is probably
missing an extra WHEN condition on it". If the compiler explains the
snafu intelligently, I think the trouble spot is solved... just not in
the mathematically-perfect way you're grasping for.

Even explaining stuff to another human involves some back 'n forth to
clarify the odd dark corner, and not all the smart rule-ordering-
precedence stuff in the world will fix that.

Rather than working further on those trouble spots, perhaps you might
think up good ways for a compiler to "figure out" how best to ask for
more information in a useful way? I feel the write-compile-test-
rewrite cycle will always be a dialogue, not a monologue.

Andrew Plotkin

unread,
May 5, 2009, 3:01:59 PM5/5/09
to
Here, Ron Newcomb <psc...@yahoo.com> wrote:
>
> Interesting read.
>
> On May 5, 7:41�am, Andrew Plotkin <erkyr...@eblong.com> wrote:
> > Really, I'd like the compiler to make *some* assumptions beyond strict
> > logical implication. Otherwise conflicts are just too common. But this
> > is up in the realm of guesswork.
>
> I would say "up in the realm of heuristics". The H-word echoed loudly
> in my skull while I was in the "trouble spots" section of the talk.

I meant, guesswork in deciding whether conflicts really *are* going to
be that common. Maybe I don't need to worry about this at all. But I
can't tell without building a language and then a standard library and
then a game.

I7 gives us some experience to analogize from -- but it's an imperfect
analogy, because its syntax-resolution scheme is so complicated.

Heuristics are tricky to work with, because you need some sort of
stability assurance. (Stability in a technical sense, like "stable
sort".) You need to believe that throwing in one more rule isn't going
to flip several unrelated decisions elsewhere in the code. The smarter
your heuristics get, the harder it is to make those assurances.

This is not to say I'm against heuristics -- just that I want to get a
sense of how much I need them first.

namekuseijin

unread,
May 5, 2009, 4:41:21 PM5/5/09
to
Andrew Plotkin escreveu:
> <http://eblong.com/zarf/essays/rule-based-if/index.html>

Out of time to read it right now.

> years. I then go on to talk about my crazy ideas for a *completely*
> rule-based language

How about Prolog? ;)

heh, another day there was some guy in comp.lang.lisp implementing an
"Adventure" in Lisp for the sake of learning. You did the other way
around in Lists and Lists!

BTW, this is amusing:
http://svn.pugscode.org/pugs/examples/adventure/adventure.pl

Perl6's grammar feature sounds nice. :)

--
a game sig: http://tinyurl.com/d3rxz9

Conrad

unread,
May 5, 2009, 7:45:53 PM5/5/09
to
On May 5, 12:36 am, Andrew Plotkin <erkyr...@eblong.com> wrote:

> <http://eblong.com/zarf/essays/rule-based-if/index.html>
>
> The description of I7's rule model, and why it exists, will be
> familiar to anybody who's been hanging around RAIF for the past few
> years. I then go on to talk about my crazy ideas for a *completely*
> rule-based language; those aren't new either, but I don't expect that
> everybody has been tracking my sporadic newsgroup ramblings on the
> subject.

I understand this well enough that I can hum along (back in my wild
college days, I was into Prolog). Automatic correction of rule
conficts? Pretty impressive.

Conrad.

David C.

unread,
May 5, 2009, 9:35:13 PM5/5/09
to
On May 5, 11:42 am, Andrew Plotkin <erkyr...@eblong.com> wrote:

I figured as much.

If I think about the MDDB approach a bit more, it comes out like
this...

MDDB designs have dimensions and time. So if you have SALES (Cost of
Goods Sold, Units Sold, Gross Revenue, Net Profit), REGION (Northeast,
Southeast, Midwest, West), PRODUCT (Widget, Gadget, Fidget), and TIME
(2008Q1, 2008Q2, 2008Q3, 2008Q4), you can create reports that show any
of the intersections of these things and any aggregations of the
intersections.

So if we move over to the IF metaphor, we might have

CHARACTER (PC, George, Henry, Paul, Dave, Fred, Sue, Angela)
OBJECT (Lamp, Sword, Wand, Rock, Flowers, Bottle, Water)
ROOM (Living Room, Dining Room, Garden, Woods, Cave, Fountain, Lake)
ACTION (get, drop, kill, throw, kiss, kick, pull, push, dig)

(not sure what the actual dimensions would be...i'm thinking out loud
here and sharing prematurely)

So then your atoms would be the data within the intersections and the
condition of the atom would use an MDX (ansi standard mddb query
language) like query to determine its state.

This still doesn't tell us what order all of the resulting atoms
should be executed in, but another dimension for PRIORITY may be
helpful.

Again...just thinking out loud.

David C.

Reply all
Reply to author
Forward
0 new messages