Help me clean up my source code

Hi there,

Very new to inform 7. I’m just using it for a little project.

Currently, I have an NPC, who can respond to certain questions. The player can “ask about [question]” and the responses are in a table. This is not a problem, as long as the player can ask the EXACT question the NPC has a response for.

I’m having a little trouble trying to redirect player alternative questions to questions in the table. For example, I want to the same response when the player asks about “liberty” or if the player asks about “freedom”. In this case, it is simple, because in my table, under the TOPIC column, I can write “liberty” or “freedom”.

How ever, I also want the same answer for my extended questions - like “ask about his feelings on freedom” and “ask about his feelings on liberty”.

My initial plan was to code

Before asking about “his feeling on freedom” or “his feelings on liberty” or “liberty”;
try asking the person about “freedom”;
stop the action.

But this was met with an error. Instead, I had to break it down into individual lines. As such.

[b]Before asking about “his feeling on freedom”;
try asking the person about “freedom”;
stop the action.

Before asking about “his feelings on liberty”;
try asking the person about “freedom”;
stop the action.

Before asking about “liberty”;
try asking the person about “freedom”;
stop the action.[/b]

You can see how this would get tedious. Especially, when the NPC has about 50 responses, and each response could fit about 3-10 different player questions. Any ideas to help me clean this up?

Thanks!

-Q

The machine-dialog rabbit hole is one that many have leapt down and few have returned from. :stuck_out_tongue_winking_eye: Until computers can be turing-complete, I don’t think there’s any ideal way to do it. Every method out there is a compromise of some kind, and the practical limitations of hardware, time, and human capability prevent us from doing anything more than tack ease-of-use features onto existing methods or continually mix and recombine them.

Personally, I’d rather wimp out and railroad a player down a tree of canned but sensible dialog, rather than risking ruining the experience through a chatterbot breaking down or ask/tell hell.

Ms. Short has explored the subject in great depth. This article, summarizing different conversation methods in IF, was published in the IF Theory reader:

http://emshort.wordpress.com/how-to-play/writing-if/my-articles/conversation/

Despite being a bit of an old article, I’ll go out on a limb and risk being excommunicated and say again that there is nothing really new that can be done here until computers can become turing complete (which may or may not ever happen, depending on who you talk to; I personally opine Not), so the article is still perfectly valid. She also has other very interesting (and newer) articles on the topic on her site.

It’s possible to put fairly complex matching features into a topic column, and to make specialized tokens that you can reuse in multiple topic contexts (see 17.13 for more about new tokens). So for instance you could make a “feelings” token that you could then slot in lots of places, like so:

[code]Moscone is a room. Bob is a man in Moscone.

Instead of asking Bob about a topic listed in the table of Bob Responses:
say “[description entry][paragraph break]”.

Understand “his/her/its feeling/feelings about/on/concerning” as “[feelings on]”.

Table of Bob Responses
topic description
“liberty/freedom” or “[feelings on] liberty/freedom” “‘Freedom is super important.’”
“love/romance” or “[feelings on] love/romance” “‘Love is grand!’”

Test me with “ask bob about freedom / ask bob about liberty / ask bob about his feelings about liberty / ask bob about love / ask bob about his feelings on love”.[/code]

That said, there is a design issue you want to beware of; the more you encourage players to type in any old string of text to specify dialogue, the more you’re training them to type things you definitely won’t have covered. A common strategy is to offer topic hints, to spare the player a guess-the-noun experience trying to discover the particular phrase or phrases that are going to work.

[i posted some advice here and then thought better of it and deleted it; sorry if this edit threw anyone for a loop, but what I wrote was probably redundant – just read Emily’s article.]

@Leaf - not this changes the validity of your post, but I think your confusing turing completeness (meaning, a system that can emulate a Turing machine) with passing the Turing test. It’s the Turing test that’s about dialogue.

Which makes me wonder: are there any Eliza-type chatter bots written in Inform? Googling… Found this: http://wurb.com/if/game/512.

So it would seem! I guess I’ve failed the turing test!!! :astonished:

I guess you passed it! An expert system would have been much less likely to make that kind of mistake, wouldn’t it? :wink:

You may also want to consider using tables. See “15.13. Topic columns” in The Inform Documentation for details.

Hope this helps.