The command "get in" keeps choosing the wrong noun

I have an enterable supporter and an enterable container in the same location. If the player types “get in,” I would like to favor entering the container. But Inform seems to favor the supporter, even if I use “Does the player mean” rules to try to favor the container.

Here is an example (not the real code):

Outdoors is a room.

A sidewalk is an enterable supporter in Outdoors.

A car is an enterable container in Outdoors.

Does the player mean entering the car:
	it is very likely.
	
Does the player mean entering the sidewalk:
	it is very unlikely.
	
Test me with "get in".

But if you type “get in,” here is the result:

Outdoors
You can see a sidewalk and a car (empty) here.

>get in
You get onto the sidewalk.

This is Inform 6M62, in case it’s relevant.

I discovered that if I switch the position of sidewalk and car in the code so that the car is defined first, Inform will favor the car instead.

I can switch some sections around in my code, but I’m curious if there’s another way to get it to choose the right noun. “Does the player mean” doesn’t seem to do anything. The player typing “get in” vs. “get on” also doesn’t seem to affect which noun is chosen.

For supplying a missing noun when entering:
  if the player's command matches "get in", now the noun is a random enterable container in the location;
  else now the noun is a random enterable supporter in the location;

You’d want to extend it to choose a touchable enterable thing over an untouchable one if that situation is liable to occur…

2 Likes

That’s very helpful–thank you!

1 Like

A bit more background on this…

The Standard Rules includes:

Entering is an action applying to one thing.
...
Understand "get in/on" as entering. [ <-- note this line]
...
Understand "get in/into/on/onto [something]" as entering.
...
Rule for supplying a missing noun while entering (this is the find what to enter rule):
	if something enterable (called the box) is in the location,
		now the noun is the box;
	otherwise continue the activity.

The find what to enter rule is listed last in the for supplying a missing noun rulebook.

The entering action is defined as requiring a noun, but a grammar line is supplied with no token for accepting a noun. That’s why the rule for supplying a missing noun works while does the player mean rules do not.

I’m not up for delving into the parser code today, but it may be possible to get the does the player mean rules to be applied in this type of situation.

1 Like

Thank you for the background, @otistdog!

Thank you! I was able to adapt Zed’s code to do what I need, so there’s no need to do any more delving, for my sake at least.