[solved] Why did I zap "deciding the scope?" (used 'player')

I was tidying up the code for my IFComp entry, and the part in question boils down to this:

[code]A jerk is a kind of man.

room 1 is a room. room 2 is north of room 1. room 3 is north of room 2. room 4 is north of room 3.

Biff is a jerk. Biff is in room 4.

Tad is a jerk. Tad is in room 3.

Dylan is a jerk. Dylan is in room 2.

Chad is a jerk. Chad is in room 1.

[if you comment out the line below, we scope properly. If not, we don’t.]
a utility player is a thing.

After deciding the scope of the player:
say “Scoping!”;
place room 2 in scope;

before doing something with a jerk:
if location of player is not location of noun:
say “Man, [noun]'s nowhere near. You don’t even want to think about him right now.” instead;

test ohno with “x biff/x tad/x dylan/x chad”;

In the example above, X DYLAN gives the sort of reaction I want–as long as you comment out the seemingly irrelevant “a utility player is a thing.” Otherwise, Inform fails to decide the scope.

Why did this happen? I’m baffled. And how do I check for certain keywords that might cause this sort of behavior from Inform in the future? Does “utility player” have some meaning in Inform I’m not aware of?

This sort of thing seems like it happens rarely, and in fact I’m surprised it didn’t happen sooner…but all the same, if I can avoid a silly mistake in the future, that’d be wonderful.

I haven’t tested this, but I bet that one or both of the following lines that mention “the player” wind up referring to your “utility player” object, instead of the (global variable) “player”.

I7 doesn’t have keywords in the usual programming language sense. Names refer to things in the code; partial names are disambiguated; occasionally the disambiguation can surprise you.

You could work around this (assuming I’m not totally wrong) by saying

A utility-player is a thing. The printed name is "utility player".
Understand "utility", "player" as the utility-player.

This is more verbose, but unambiguous.

The problem (in a sense) seems to lie with the ‘after deciding the scope of’ rule.

Inform does interpret the word “player” in the rule as a name of the utility player object rather than as a name of the player variable.
(If anyone wonders: you can see that by searching for “deciding the scope” in the auto.inf text file that translates the project into I6 – it’s in the build folder of the .inform folder of the project (on a Mac it’s a “package” that looks like an application and has to be opened by right-clicking/ctrl-clicking).)

The ‘before doing something with’ rule, however, gets the intended interpretation – unless you’re too explicit:

Before the player doing something to a jerk:

will be interpreted as ‘the utility player doing something to a jerk’ (but the location is still tested for the player variable).

Thanks very much for the explanations. I was able to fix things by privately naming things, but it’s very good to be able to understand that much more.

For some reason I didn’t think to tinker with the name to see which word caused things to go funny. But it makes sense now.

I thought I put the scope text at both the end and beginning of the file to see if that made a difference, but maybe I didn’t. One more thing to double check.