How to make conversation not case sensitive?

I decided to start working on fixing a section of dialog gradually, by first changing the INSTEAD OFs to CARRY OUTs.

Carry out asking the Waitress about something:
     say "[one of]'I simply don't know what you mean.'[or]'That seems irrelevant.'[cycling]"

Carry out asking the Waitress about something when the topic understood matches the regular expression "\bdiner":
     say "I had to work to get this place. I don't know why or how."

ask waitress about diner now yields:

"I had to work to get this place. I don't know why or how."

"That's simply not important now."

There is no reply.

When things said “instead of”, You’d get only the appropriate reply.

For now, I am going with the “topic understood in lower case” band-aid so I don’t break my game. If I can figure out how to “fix” my dialog without breaking it simultaneously, I’ll redo everything.

My recommendation would be to keep the Instead rules but to use Inform’s normal parser instead of regex matching, for what it’s worth.

2 Likes

The “There is no reply” comes from the “block asking rule”, which is a Report rule (“Report an actor asking something about”).

One way to prevent that message from being printed (in those cases when people have something interesting to say or do) is to use “After” rules, which end the action as a success and prevent the Report rules from firing:

After asking Adam about "foo/bar/baz":
	say "Adam nods.".

This will only print “Adam nods.”, not “There is no reply.”.

1 Like

In my ever-humble opinion, the doc examples overuse Instead rules. Daniel did a good job laying out the thinking behind it, but I’d submit variously:

  • if you’re just forwarding something to a different action, a Before rule’s a better choice. Using an Instead rule instead of a Before rule just buys you an extra trip through the visibility/accessibility/carrying requirements rules (unless someone has a very weird and specific reason it’s a good thing to go through them the first time in the context of the original action)
  • There’s rarely a downside to pushing specific behavior into check rules, and doing so helps keep the Instead rulebook free for the really weird exceptional behavior.
  • There are a lot of anecdotes to be found in the forums of people who regret overusing Instead rules because it turned their code into a hard-to-understand hard-to-modify mess. I’ve never seen a single account saying “I wish I hadn’t used Check rules so much”. (I’m sure there are instances of “Hey, this discrete thing would have been better as an Instead rule”, but that’s a different thing from “I wish I’d automatically reached for Instead rules more often.”)

(That’s just one person’s opinion and there are people with far more experience than I have who embrace Instead rules for more things than I would, so take it as you will.)

You got disappointing results here 'cause every applicable Carry Out rule in the action’s Carry Out rulebook runs. You’d have to stop the action to keep from proceeding to the next. The docs advise structuring things in a way that minimize using explicit stop/continue the action (and if recollection serves they don’t make very clear that stop the action doesn’t do what you expect in the Carry Out rules: it stops that rulebook, but you continue to the After rules normally).

If you’re dealing with a situation that doesn’t change the game state and makes you tempted to stop the action in a Carry Out rule, it’s a good sign that you’d be better off with Check or Instead for that case. (Or maybe an After rule, as @StJohnLimbo just suggested, but I’d been assuming the “simply not important” was from a different Carry Out rule.)

4 Likes

That’s a little over my head but you’ve given me some key terms to look for.

I am a pretty bad coder and have been cobbling games together the only way I know how, which involves a lot of uses of “instead.” From what you’re saying, I’m probably going about things the wrong way. I’ll see if I can figure out how to use Check and Carry Out.

My current predicament is that a collaborator and I are trying to slam out a game by the ECTOCOMP deadline. The dialog works as-is though we have had to up the MAX_STATIC_DATA and I’m wondering if that problem was caused by the way we are handling dialog. Anyway, for our workflow we have to pass working copies of the game back and forth a couple of times a day, so if I’m going to break anything I have to be prepared to fix it immediately on the spot. Right now I don’t know how to do that.

I’ll read up on dialog and Check and Carry Out though and see if I can figure out a better way to structure dialog. I’m thinking there’s probably some way I could put this all in a table or something.

1 Like

If you’re working toward the ECTOCOMP deadline, I definitely don’t think switching to check/carry out rules is worth it. I do think switching to use Inform’s parsing facilities instead of regexes will save you a lot of time in testing and debugging, though.

2 Likes

Thanks, I will try to figure that out.

Instead of asking Waitress about something:
     say "[one of]'That's simply not important now.'[or]'That seems irrelevant.'[cycling]".

Instead of asking Waitress about "diner/work/job":
     say "I had to work to get this place.  I don't know why or how."

ASK WAITRESS ABOUT DINER

yields

"That's simply not important now."

What I’m trying to accomplish is that when the waitress is asked about a topic we have accounted for, she gives an appropriate answer. When the waitress is asked about a topic we haven’t accounted for, she gives a throwaway answer. This worked using the regular expression thing.

Wild stab in the dark here: try putting the irrelevant rule at the end of the instead rule book? (Or just declare it last?)

1 Like

WOW! That worked. Thanks!

This behaviour occurs because the first rule “Instead of asking … about something” kicks in first, because it is listed first in the source, and it applies, because it is completely general. (In some contexts, more specific rules override more general rules, but this is not one of them.)

If you reverse the order of the rules in the source code, you’ll see that it works. But to rely on the source code order can lead to a brittle solution.

So, one way to get the desired results would be like this:

After asking the waitress about "diner/work/job":
	 say "I had to work to get this place.  I don't know why or how."
	
Report asking the waitress about something:
	say "[one of]'That's simply not important now.'[or]'That seems irrelevant.'[cycling]".

The block asking rule does nothing when asking the waitress about something.

The “After” rule will prevent the “Report” rule from running in the appropriate cases.
We additionally need to conditionally disable the aforementioned “block asking rule”, otherwise the reply “There is no reply” will be added in the “not important” case, when our own report rule runs.

3 Likes

I switched to this recommended After / Report / Block Asking DOes Nothing format, and the parser gives appropriate responses to some topics but then gives the throwaway response to other topics which should be defined.

Hm, can you give an example where it doesn’t work?

`[TALKING TO WAITRESS]

After asking Waitress about "diner/work/job":
	say "'I had to work to get this place. I don't know why or how.'"
	
After asking the unsaved Waitress about "hell":
        say "'Hell is where God's light isn't. Tell me when you find the church...'"

After asking Waitress about "church":
        say "'Exactly. What church? A place designed like this without a church?'"

After asking Waitress about "food/menu":
	say "'Nothing but grease and cholesterol.'".

[After asking Waitress about "toy/toys/toy store/toy shop/toystore/toyshop":
	say "'The old man in the toy store says he loves giving toys to children. I've never seen any children here.'"]

After asking Waitress about "child/kid/children/kids":
	say "'I can't remember the last time I saw a kid anywhere.'"
	
[After asking the unsaved Waitress about "old man/kindly old man/kind old man":
	say "''He seems friendly enough. Just like everyone else.'".]
	
[After asking Waitress about "apartment/apartment building":
        say "'I don't think I've ever seen anyone exit or enter. Even the windows seem foggy. Makes me wonder if someone else is trapped there, for all eternity.'".]
	
After asking the unsaved Waitress about "herself/woman/waitress/her":
	say "'I hardly know you. Not enough to tell you about my past.' She tries to give you a coy smile that just seems creepy.".

After asking Waitress about "nurse":
	say "'She looks at me funny whenever I enter the doctor's office. I don't know why.'".

[After asking the unsaved Waitress about "gun/toy gun":
	if the player carries the toy gun:
		say "'Don't you have better things to do than playing with toys?' she sighs.";
	otherwise:
		say "'Toy gun? What are you talking about?'"]

After asking the unsaved Waitress about "max/me/self/myself/player":
	say "'I don't know anything about you, do I?'"

[After asking the unsaved Waitress about "candy man/candy":
	say "'DO YOU LIKE CANDY AND NUTS!? If I could still sleep, he would occupy my nightmares.'"]

After asking the unsaved Waitress about "dressmaker/fancy lady/lady":
	say "'I could do with a nice dress, but that attitude is how I got here.'"
	
After asking the unsaved Waitress about "clothing clerk/clothing/clerk":
	say "'There's something off about that guy.'".
	
After asking Waitress about "library":
	say "'Its amazing what you can read if you have the time. Geheel ander talen. Its almost a boon...almost.'".

After asking the unsaved Waitress about "librarian":
	say "'She's a very nice lady.'".
	
[Instead of telling the unsaved waitress about "void/blue void/basement":
	if the blue void is in Eerie Basement:
		say "The waitress looks startled, 'Really? I've got to see this. I'll meet you there.'[paragraph break]The woman dashes out of the diner in a rush.";
		now the waitress is in Eerie Basement;
		now the savedness of the waitress is saved;
	otherwise:
		say "'What are you trying to say?'".
		
Instead of asking the unsaved waitress about "void/blue void/basement":
	if the blue void is in Eerie Basement:
		say "The waitress looks startled, 'Really? I've got to see this. I'll meet you there.'[paragraph break]The woman dashes out of the diner in a rush.";
		now the waitress is in Eerie Basement;
		now the savedness of the waitress is saved;
	otherwise:
		say "'What are you trying to say?'".]

Instead of showing the toy gun to the unsaved Waitress:
	say "'Don't you have better things to do than playing with toys?' she sighs."

Instead of talking to the unsaved Waitress:
	say "She looks offended, 'Cut the inane chatter.  If you have something important to ask me, ask me.'"

Report telling Waitress about something:
	say "[one of]'I simply don't know what you mean.'[or]'Is that so?'[cycling]".

Report asking Waitress about something:
	say "[one of]'That's simply not important now.'[or]'That seems irrelevant.'[cycling]".

The block asking rule does nothing when asking the Waitress about something.
The block telling rule does nothing when telling the Waitress about something.`

Anything that is commented out didn’t work correctly.

The slash which separates the vocabulary parts which Inform shall recognize is a bit tricky to use. The rules are laid out in 17.12. This/that and 17.13. New tokens.

Quoting from there:

note that the slash indicates a choice between words only, not between entire phrases. For instance, if we write:

Understand "red bird/robin" as "[robin]".

then the two alternative forms are “red bird” and “red robin”, not “red bird” and “robin”. By contrast,

Understand "red bird" or "robin" as "[robin]".

will understand either “red bird” or “robin” but not “red robin”. If we want to capture all three forms, we might define

Understand "red bird/robin" or "robin" as "[robin]".

Another example, if you want the parser to recognize all combinations of “the diner/the work/the job/diner/work/job”, you’d do it like this:

After asking the waitress about "the/-- diner/work/job":
	 say "I had to work to get this place.  I don't know why or how."

(The -- means that the preceding part is optional.)

4 Likes

Thanks all!

I think I’ve got all the dialog fixed. I may not be using best practices, but what I’ve got is a lot better than what I had. I’ll try to figure out how CHECK and CARRY OUT work so I can do better in the future.

2 Likes

I agree with this 100%. While I understand that the intent is to gradually acclimate authors to the rules system, this feature of the documentation seems to instill either a belief that this is the preferred method in most cases, or at the very least a habitual over-reliance in them. To what the others have said about this, I would add that extensive use of instead rules can make debugging more of a pain. There is one instead rulebook which covers all actions, whereas each action has its own set of check, carry out and report rules. In other words, if you are debugging with “rules all” tracing on, you will see all of your instead rules every time.

2 Likes

I found this post very helpful

Check, Carry out and Report

3 Likes

Here’s another good description, by @HanonO :

And another useful thread on the subject…

4 Likes