Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I7: revisiting three nouns

4 views
Skip to first unread message

weevil

unread,
Dec 4, 2009, 1:34:32 AM12/4/09
to
Does anyone know how to apply this:
http://groups.google.com/group/rec.arts.int-fiction/browse_thread/thread/8b7ca0bf314dd714/e67520b1dadc372f?lnk=gst&q=three+nouns#e67520b1dadc372f

to this:
http://groups.google.com/group/rec.arts.int-fiction/browse_thread/thread/9fa2998deebc61f6/2cd61caca55d00fc?lnk=gst&q=drawing#2cd61caca55d00fc

In short: I have a piece of paper, some crayons, and the suggestion
that the player draw something on the paper, and it matters what they
draw. 90% of the people I tested the game on try "draw *subject* on
the paper with the red crayon" or something similar. The problem of
course is three nouns.

I've been staring at the 'Third noun' hack that someone posted long
ago here, and trying to slowly apply it to my problem, and it is
making me feel that I myself am slow. Can anybody help?

Erik Temple

unread,
Dec 4, 2009, 8:06:10 AM12/4/09
to


That looks like a very cool hack. So what exactly do you need help with?
It's been three years since it was posted; my guess is that the parser
hasn't changed enough that the hack would now be impossible, but I'm not
positive. Have you managed to get the example itself working? I'd try that
first, if you haven't already.

--Erik

weevil

unread,
Dec 4, 2009, 11:13:54 AM12/4/09
to
I don't know how to alter it so it would work like draw [text] on
[something] with [something] since it seems to be working with tokens
in a text chunk. Would I change the definition of my drawing verb to
just draw [text] with [something] and put a token in the text for the
paper?


On Dec 4, 7:06 am, "Erik Temple" <ek.tem...@gmail.com> wrote:


> On Fri, 04 Dec 2009 00:34:32 -0600, weevil <wileywg...@gmail.com> wrote:
> > Does anyone know how to apply this:

> >http://groups.google.com/group/rec.arts.int-fiction/browse_thread/thr...
>
> > to this:
> >http://groups.google.com/group/rec.arts.int-fiction/browse_thread/thr...

Erik Temple

unread,
Dec 4, 2009, 11:33:47 AM12/4/09
to

The hack basically consists of getting the parser to first parse the
player's command into a verb + noun plus a text token, and then
parsing the text token further as needed. So, provided that the
subject of your drawing will be a thing token (and not indexed text,
for example), you would do:

"draw [something] [text]"

And then do the parsing of the text token as needed, and as seen in
the example code posted by JDC. Does that make sense?

--Erik

weevil

unread,
Dec 4, 2009, 12:16:00 PM12/4/09
to
That's the problem, the subject of the drawing is not a thing token,
it's text. Part of the joke is that people keep mentioning whatever
madlib-style thing the character supplied for his drawing, and it
needs to be free text.

Erik Temple

unread,
Dec 4, 2009, 12:35:18 PM12/4/09
to
On Dec 4, 11:16 am, weevil <wileywg...@gmail.com> wrote:
> That's the problem, the subject of the drawing is not a thing token,
> it's text. Part of the joke is that people keep mentioning whatever
> madlib-style thing the character supplied for his drawing, and it
> needs to be free text.

The link to your sample code in the original post is parsing a thing
as the subject. This is trickier.

You could do something like this, I think:

"draw [indexed text] on [text]"

which will allow for:

"draw a bunny on the paper with the red crayon"

This will require your player to use the word "on"; if she doesn't,
the grammar won't be recognized. Also, if the word "on" appears in the
subject of the drawing, things will not be parsed correctly. In other
words, if the player writes "draw a dwarf on a horse on the paper",
the indexed text token will be "dwarf" and the text token will be "a
horse on the paper". You could probably do some testing before parsing
the command that would look for two "on"s and redirect to a different
grammar.

Because you won't have a preposition to anchork your subsequent
parsing of the first part of the text token (i.e., the thing drawn
on), you would want to parse using a kind or description, e.g. "if the
topic understood contains "[something drawable]", change the second
noun to the noun". This isn't ideal, perhaps, but it should work.

--Erik

weevil

unread,
Dec 4, 2009, 2:29:05 PM12/4/09
to
The drawing subject is currently just text and not indexed text.
Should I change it to indexed text per your example to get this to
work?

Erik Temple

unread,
Dec 4, 2009, 2:38:21 PM12/4/09
to
On Fri, 04 Dec 2009 13:29:05 -0600, weevil <wiley...@gmail.com> wrote:

> The drawing subject is currently just text and not indexed text.
> Should I change it to indexed text per your example to get this to
> work?

No, I was being very silly. First, Inform doesn't understand "indexed
text" in grammar lines, and--more importantly--you can't do two values
(like text) in one grammar line anyway.

I think you could still get JDC's hack to work, but there might be an
easier way to hack this in (untested, no guarantees):

Isolate the indexed text token early on, maybe even in "before reading a
command". Remove it from the command entirely using pattern matching and
put the subject in a global indexed text variable (e.g., the current
drawing subject).

Now you can write a grammar line like this:

Understand "draw on [a thing] with [a crayon]" as drawing.

So, if the player types:

"Draw a bunny on the paper with the red crayon"

You strip out "a bunny" before reading the command and assign it to the
"current drawing subject" variable, leaving this to be parsed:

"Draw on the paper with the red crayon"

To be sure that the player doesn't simply type "Draw on the paper with the
red crayon", you check whether the current drawing subject has a value
assigned to it. If it doesn't, the player hasn't specified a subject and
you can have the game give an appropriate response.

Does this sound like it would work?

--Erik

weevil

unread,
Dec 4, 2009, 3:06:24 PM12/4/09
to
So am I abandoning JDC's example altogether now? which parts do I
keep?
Is 'Drawing it on it is an action applying to one thing and one
topic.' still?

I'm sorry I'm having a hard time with this, I haven't ever really used
'the topic understood' in a game before.

Erik Temple

unread,
Dec 4, 2009, 4:31:49 PM12/4/09
to


I was suggesting moving away from JDC's example entirely, but you could
cook something up that uses his technique. It's just not necessary. My
suggestion doesn't involve any parsing of the topic understood (which is
just Inform's way of referring back to the part of the player's command
that matches the "text" token in the grammar).

Anyway, here's an example of how you could do things the way I suggested:

<code>
The Scriptorium is a room.

A crayon is a kind of thing. The greasepencil is a crayon in the
Scriptorium.

A drawable is a kind of thing. The paper is a drawable in the Scriptorium.

The current drawing subject is an indexed text variable. The current
drawing subject is "".

After reading a command:
change the current drawing subject to "";
if the player's command matches the regular expression "^draw ", case
insensitively:
let T be indexed text;
let T be the player's command;
replace the regular expression "^draw " in T with "";
if T matches the regular expression "(.+) on":
change the current drawing subject to T;
replace the regular expression " on .+" in the current drawing subject
with "", case insensitively;
replace the regular expression "(^a |^an |^the |^this |^that)" in the
current drawing subject with "", case insensitively;
replace the regular expression "(^\s|\s$)" in the current drawing
subject with "";
replace the regular expression "(.+) on" in T with "on", case
insensitively;
let T be "draw [T]";
change the text of the player's command to T;
[say "[the player's command].";
say "[the current drawing subject].";]

Drawing is an action applying to two visible things. Understand "draw on
[a drawable] with [a crayon]" as drawing.

Check drawing:
If the current drawing subject is "":
say "Please indicate what you wish to draw, e.g. DRAW A DUNG BEETLE ON
THE PAPER WITH THE CRAYON.";
rule fails.

Carry out drawing:
Say "You draw a [current drawing subject] on the [noun] with [the second
noun]. Looks mighty fine!";

Test me with "get all / draw a thirty-ton bomb on the paper with the
greasepencil"
</code>

This solution is still vulnerable to the problem that the player cannot
use the word "on" in her subject--no writing "draw a horse with a bird on
it on the paper with the crayon". You could probably fix this by jiggering
the regular expressions a bit, so that if there are two "on"'s in the
command, it breaks the command on the second "on" rather than the first.

You might have to mess around with the treatment of articles within the
player's drawing subject. The code above simply strips any initial article
out. That may be the way you want to go, but it may not.

Let me know if this does the trick.

--Erik

JDC

unread,
Dec 4, 2009, 5:06:31 PM12/4/09
to
Gee, I'm late to the party, but I suppose I can throw in a few
comments. I should warn that I haven't thought about this any more in
the intervening three years. But on an entirely irrelevant note, I did
get to see the Riesenrad in the Prater this summer...

On Dec 4, 4:31 pm, "Erik Temple" <ek.tem...@gmail.com> wrote:

> I was suggesting moving away from JDC's example entirely, but you could  
> cook something up that uses his technique. It's just not necessary. My  
> suggestion doesn't involve any parsing of the topic understood (which is  
> just Inform's way of referring back to the part of the player's command  
> that matches the "text" token in the grammar).

I would definitely do this the way Erik has shown when trying to match
text. Inform now has regular expression matching (which it didn't at
that time), which makes this much easier. At that time, you could only
match literal text strings, or use the parser's noun parsing to pick
out objects (which was what my code did). The main advantage of my old
code was for matching objects, since you could recognize all the
possible synonyms for an object name (which is a bit cumbersome with
regex's; I once thought of trying to hack the regex code in Inform to
be able to match object tokens, but never got around to it); this is
unnecessary when looking for arbitrary text as you are here.

> This solution is still vulnerable to the problem that the player cannot  
> use the word "on" in her subject--no writing "draw a horse with a bird on  
> it on the paper with the crayon". You could probably fix this by jiggering  
> the regular expressions a bit, so that if there are two "on"'s in the  
> command, it breaks the command on the second "on" rather than the first.

You should be able to use a greedy match in the regular expression (I
don't have the syntax handy right now, but I think Inform supports
this), which will grab the longest text fragment followed by "on" (and
hence split before the last "on").

-JDC

weevil

unread,
Dec 4, 2009, 5:38:26 PM12/4/09
to
It works!
almost...

I'm adapting your example to work with what I was already using, and
there's just one tiny snag- I want the name and description of the
paper to turn into a drawing of [current drawing subject].

I've changed the variable from 'current drawing subject' to 'drawing'
and the item to drawable-paper, even though your names are frankly
better, because my game is filled with hundreds of references to the
variables under those names.

Here's what I have right now, everything works but the name and
description of the paper after you've drawn on them.


<code>

The Scriptorium is a room.

A crayon is a kind of thing. The greasepencil is a crayon in the
Scriptorium.

The drawable-paper is in the scriptorium. The drawing is an indexed
text variable. The description of the drawable-paper is "[if drawn
upon]On the paper you have drawn [drawing][otherwise]The paper is blank
[end if]."

Instead of eating the drawable-paper, say "You nibble a bit on the
edge, but find it a poor substitute for a banana."

The printed name of the drawable-paper is "[if drawn upon]drawing of
a
[drawing][otherwise]piece of paper". Understand
"piece", "paper", and "piece of paper" as the drawable-paper. The
drawable-paper can be drawn upon. The drawable-paper is not drawn
upon.
Understand "drawing" as the drawable-paper when the drawable-paper is
drawn upon.

[A drawable is a kind of thing. The paper is a drawable in the


Scriptorium.
The current drawing subject is an indexed text variable. The
current
drawing subject is "". ]

After reading a command:
change the drawing to "";


if the player's command matches the regular expression "^draw ",
case
insensitively:
let T be indexed text;
let T be the player's command;
replace the regular expression "^draw " in T with "";
if T matches the regular expression "(.+) on":

change the drawing to T;
replace the regular expression " on .+" in the drawing with "",


case insensitively;
replace the regular expression "(^a |^an |^the |^this |^that)" in

the drawing with "", case insensitively;
replace the regular expression "(^\s|\s$)" in the drawing with "";


replace the regular expression "(.+) on" in T with "on", case
insensitively;
let T be "draw [T]";
change the text of the player's command to T;
[say "[the player's command].";

say "[the drawing].";]

Drawing is an action applying to two visible things. Understand "draw
on

[drawable-paper] with [a crayon]" as drawing.

Check drawing:
If drawing is "":


say "Please indicate what you wish to draw, e.g. DRAW A DUNG BEETLE

ONTHE PAPER WITH THE CRAYON.";
rule fails.

Carry out drawing:
Say "You draw a [drawing] on the [noun] with [the second noun].";
now the drawable-paper is drawn upon.


Test me with "get all / draw a thirty-ton bomb on the paper with
the

greasepencil/examine paper"
<code>

Erik Temple

unread,
Dec 4, 2009, 5:58:16 PM12/4/09
to
On Fri, 04 Dec 2009 16:38:26 -0600, weevil <wiley...@gmail.com> wrote:

> It works!
> almost...
> I'm adapting your example to work with what I was already using, and
> there's just one tiny snag- I want the name and description of the
> paper to turn into a drawing of [current drawing subject].

In the example as I wrote it, the drawing variable is reset to null every
time a command is read, so there's no value in it to read. Just change the
beginning of the "after reading a command" rule to:

After reading a command:


if the player's command matches the regular expression "^draw ", case
insensitively:

change the drawing to "";


let T be indexed text;

etc.

and it will work. That's a better way of doing it anyway.

Actually, you'll probably want to change most of the drawing commands,
including the after reading a command rule, so that the player can't draw
on the paper a second time.

--Erik

weevil

unread,
Dec 4, 2009, 6:29:21 PM12/4/09
to
You are a god. I'm naming my first-born after you.


On Dec 4, 4:58 pm, "Erik Temple" <ek.tem...@gmail.com> wrote:

0 new messages