Computers by Emily Short - strange behavior

I’m using Emily Short’s fantastic extension “Computers”, many thanks to her for writing such a monumentally useful extension. However, I’m noticing some strange behavior.

I have a computer named computer, and a search engine named chrome running on the computer with a no-records response set up.

Check the transcript below:

[code]>look up sandwiches in chrome
[I didn’t recognize all of the words in that command.]

search for sandwiches
[That isn’t available.]

look up sandwiches on computer
You attempt to look it up, but it appears that the computer is disconnected from the internet.

look up sandwiches on chrome
You attempt to look it up, but it appears that the computer is disconnected from the internet.

search for sandwiches
You attempt to look it up, but it appears that the computer is disconnected from the internet.[/code]I’ve tried to put in a “Does the player mean text-searching some text in chrome: it is very likely.” line, but that does nothing to help.
Apparently inform doesn’t know I’m talking about the search engine program until I remind it that the search engine is running on the computer?
This is strange and inconvenient behavior from an otherwise fantastic extension. Has anyone else run into this?
As a side note, I’ve included the “quittable program” modifier from the “operations” example in Emily’s extension documentation. Might this be interfering?

You ask it to look up sandwiches in chrome the first time, and on chrome the second. Is that part of the problem?

It shouldn’t be, I don’t think; the extension contains this line:

Understand "look up [text] on/in [something]" as consulting it about (with nouns reversed).

Joel, I think it might help if you posted a little more of your code, in case this isn’t a bug someone’s already discovered.

UPDATE: Have you tried turning off Aaron Reed’s extension, which I think you’re using? Perhaps the issue is with the interaction between those.

Overly simplified story:[code]“Test” by Joel Webster

Include Plurality by Emily Short.
Include Player Experience Upgrade by Aaron Reed.
Include Menus by Emily Short.
Include Basic Help Menu by Emily Short.
Include Locksmith by Emily Short.
Include Modern Conveniences by Emily Short.
Include Basic Screen Effects by Emily Short.
Include Automated Drawers by Emily Short.
Include Computers by Emily Short.

The apartment is a room.

The desk is a supporter in the apartment.

The PC is a desktop computer on the desk.
The PC runs a search engine called chrome. The software priority of chrome is 5. The description of chrome is “Google Chrome internet browser”.
The no-records response of chrome is “Nope”.[/code]This story functions exactly as expected, with “look up in chrome” functioning perfectly.

However, the following story does not:[code]“Test 2” by Joel Webster

Include Plurality by Emily Short.
Include Player Experience Upgrade by Aaron Reed.
Include Menus by Emily Short.
Include Basic Help Menu by Emily Short.
Include Locksmith by Emily Short.
Include Modern Conveniences by Emily Short.
Include Basic Screen Effects by Emily Short.
Include Automated Drawers by Emily Short.
Include Computers by Emily Short.

The apartment is a room.

The desk is a supporter in the apartment.

The PC is a desktop computer on the desk.
The PC runs a multiple-choice program called desktop. The options table of desktop is the Table of GUI Options. The software priority of desktop is 1.
The PC runs a search engine called chrome. The software priority of chrome is 5. The description of chrome is “Google Chrome internet browser”.
The no-records response of chrome is “Nope”.

Table of GUI Options
topic title effect
“internet/browser/chrome” “Chrome” open-chrome rule

This is the open-chrome rule:
repeat with item running through software run by the PC:
now the software priority of item is 5;
now the software priority of chrome is 1;
say “You open the internet browser.”;
try examining chrome.

Software can be quittable. A software is usually not quittable. Chrome is quittable.

A first input handling rule for quittable software (called chosen software):
let N be indexed text;
let N be the topic understood;
if N is “quit”:
reset to operating system;
say “You return to the desktop.”;
try examining desktop;
rule succeeds.

To reset to operating system:
repeat with item running through software run by the PC:
now the software priority of item is 5;
now the software priority of desktop is 1;

After examining a quittable software (called chosen software):
say “You can also select QUIT to return to the desktop.” [/code]
This code reliably duplicates the behavior I noted earlier.
I’m beginning to think that making software quittable is what is causing the strange behavior.
I’ll try playing around with that rule to see if I can get it to behave.

This is a real stab in the dark, but could it be that in the second example chrome isn’t running at the beginning (its software priority starts out as 5), and when you try “look up sandwiches on computer” that runs the open-chrome rule and it is running? And maybe before then “chrome” gives you a scope problem? What happens if you switch the initial priority of the operating system and chrome?

YOU’RE RIGHT.
What in the world? It looks like running the open-chrome rule doesn’t actually open chrome.

So what I need to figure out now is how to make it so that when I select chrome from the multiple-options program “desktop” it will truly put the desktop in the background and put chrome in the foreground. I thought that the open-chrome rule took care of that, but I see that it actually doesn’t.

Are you sure the open-chrome rule has run by this point, though? I thought that your first command might not even find “chrome,” because the program isn’t running, and then the third command caused the “open chrome” rule to run so subsequent references to “chrome” were understood. Maybe “look up” activates the search engine even if it’s not the active program, as long as the command is understood? I’m just guessing, though.

You should definitely turn on rules tracing in your test case if you haven’t (apologies if you have).

I never knew I could.
Now when I trace the rules I see that the “pick a choice” rule fires, which is defined in the source as follows:An input handling rule for a multiple-choice program (called chosen software) (this is the pick a choice rule): if the topic understood is a topic listed in the options table of the chosen software: follow the effect entry; rule succeeds; otherwise: say "[out of bounds response of the chosen software][paragraph break]"; rule fails.But the “effect entry” (which is the open-chrome rule) is not listed in the rule trace. Also, when looking it up in chrome, I get a whole slew of unrelated rules being triggered compared to when I look it up in the computer. Also, I never see the open-chrome rule triggering, even when the search succeeds.
Curiouser and curiouser.

Partial transcript:

[code]>click chrome
[Rule “guess a selection device while selecting rule” applies.]
[Rule “find correct selection device software rule” applies.]
[Rule “default mousing rule” applies.]
[Rule “pick a choice rule” applies.]

look up sandwiches in chrome
[Rule “stripping punctuation rule” applies.]
[Rule “standardize apostrophes rule” applies.]
[Rule “standardize can verbs rule” applies.]
[Rule “signs of confusion rule” applies.]
[Rule “stripping niceties rule” applies.]
[Rule “scandalous standardize swears rule” applies.]
[Rule “stripping interjections rule” applies.]
[Rule “signs of frustration rule” applies.]
[Rule “standardize be verbs rule” applies.]
[Rule “asking where am i rule” applies.]
[Rule “stripping adverbs rule” applies.]
[Rule “unnecessary movement rule” applies.]
[Rule “stripping vague words rule” applies.]
[Rule “stripping pointless words rule” applies.]
[Rule “stripping failed with rule” applies.]
[Rule “no gerunds rule” applies.]
[Rule “generic surroundings rule” applies.]
[Rule “stripping body parts rule” applies.]
[Rule “usually no clothing rule” applies.]
[Rule “stripping possessives rule” applies.]
[Rule “stripping unnecessary addendum rule” applies.]
[Rule “too many words rule” applies.]
[Rule “fix the command rule” applies.]
[Rule “Remembering replace did not make sense in that context rule” applies.]
[I didn’t recognise all of the words in that command.]

look up sandwiches in pc
[Rule “consult only software rule” applies.]
[Rule “list search hits rule” applies.]
No records found.

[/code]

Brief solution: change your open-chrome rule to

This is the open-chrome rule: repeat with item running through software run by the PC: now the software priority of item is 5; now the software priority of chrome is 1; let launched program be the controlling program of the PC; say "You open the internet browser."; try examining chrome.

Long explanation (only necessary if you’re interested): behind the scenes, the extension is moving the currently-active software in and out of play in order to allow the player to interact with only the software that is supposed to be active (and hide everything else to prevent examining it, disambiguating to it, etc). And it’s intended to be doing this in a way that is transparent to the author and completely driven by the priority business, so the author doesn’t have to worry about moving objects himself and so that multiple software priorities can stack – e.g. there’s a password program layered over a UI layered over multiple openable sub-programs. So what it does is to perform a check every time it’s asked what the “controlling program” of the machine is, make sure that the top-priority software is being shown, and move that software into the screen object if it isn’t already there.

Currently, it performs that check right at the beginning of an action that is supposed to interact with the computer, such as typing or clicking something. That way, if anything happened during the previous turn to change software priority, it will update that information and respond by directing the player’s input to the right target.

Most of the time that works fine – for commands like TYPE SANDWICHES, which doesn’t mention chrome as part of the command. The problem is that if you type LOOK UP FOOBAR IN CHROME, the parser needs to know that chrome is now the dominant program and part of the screen before it parses that instruction – to put chrome in scope – and so it doesn’t get as far as firing the check that would move chrome. Doh.

In retrospect, this was not an ideal design, especially given that the author is having to invoke a bunch of other code to activate a given bit of software.

Summary: totally my fault. Thanks for bringing it up. I’ll revise this and upload a new version that won’t catch people out this way. In the meantime, the hack I recommended should fix its behavior in the short term.

It sure does, thank you so much!
I guess I’m giving your extensions a run for their money :wink: