It pretty much causes the parser to favour held things over those that aren’t in the Adjudicate function. The same thing happens with “a carried thing” but to a much smaller degree. You can see this here with this slightly adjusted version of your starting code.
"Preferably Held"
Include (-
[ Adjudicate context i j k good_ones last n ultimate flag offset;
#Ifdef DEBUG;
if (parser_trace >= 4) {
print " [Adjudicating match list of size ", number_matched,
" in context ", context, "^";
print " ";
if (indef_mode) {
print "indefinite type: ";
if (indef_type & OTHER_BIT) print "other ";
if (indef_type & MY_BIT) print "my ";
if (indef_type & THAT_BIT) print "that ";
if (indef_type & PLURAL_BIT) print "plural ";
if (indef_type & LIT_BIT) print "lit ";
if (indef_type & UNLIT_BIT) print "unlit ";
if (indef_owner ~= 0) print "owner:", (name) indef_owner;
new_line;
print " number wanted: ";
if (indef_wanted == INDEF_ALL_WANTED) print "all"; else print indef_wanted;
new_line;
print " most likely GNAs of names: ", indef_cases, "^";
}
else print "definite object^";
}
#Endif; ! DEBUG
j = number_matched-1; good_ones = 0; last = match_list-->0;
for (i=0 : i<=j : i++) {
n = match_list-->i;
match_scores-->i = good_ones;
ultimate = ScopeCeiling(n);
if (context==HELD_TOKEN && parent(n)==actor)
{ good_ones++; last=n; }
if (context==MULTI_TOKEN && ultimate==ScopeCeiling(actor)
&& n~=actor && n hasnt concealed && n hasnt scenery)
{ good_ones++; last=n; }
if (context==MULTIHELD_TOKEN && parent(n)==actor)
{ good_ones++; last=n; }
if (context==MULTIEXCEPT_TOKEN or MULTIINSIDE_TOKEN)
{ if (advance_warning==-1)
{ if (context==MULTIEXCEPT_TOKEN)
{ good_ones++; last=n;
}
if (context==MULTIINSIDE_TOKEN)
{ if (parent(n)~=actor) { good_ones++; last=n; }
}
}
else
{ if (context==MULTIEXCEPT_TOKEN && n~=advance_warning)
{ good_ones++; last=n; }
if (context==MULTIINSIDE_TOKEN && n in advance_warning)
{ good_ones++; last=n; }
}
}
if (context==CREATURE_TOKEN && CreatureTest(n)==1)
{ good_ones++; last=n; }
match_scores-->i = 1000*(good_ones - match_scores-->i);
}
! if (good_ones == 1) {
! if (indef_mode == 1 && indef_type & PLURAL_BIT ~= 0 &&
! context == MULTI_TOKEN or MULTIHELD_TOKEN or
! MULTIEXCEPT_TOKEN or MULTIINSIDE_TOKEN) {
! BeginActivity(DECIDING_WHETHER_ALL_INC_ACT, last);
! if ((ForActivity(DECIDING_WHETHER_ALL_INC_ACT, last)) &&
! (RulebookFailed())) good_ones = 0;
! EndActivity(DECIDING_WHETHER_ALL_INC_ACT, last);
! if (good_ones == 1) return last;
! } else {
! return last;
! }
! }
! If there is ambiguity about what was typed, but it definitely wasn't
! animate as required, then return anything; higher up in the parser
! a suitable error will be given. (This prevents a question being asked.)
if (context == CREATURE_TOKEN && good_ones == 0) return match_list-->0;
if (indef_mode == 0) indef_type=0;
ScoreMatchL(context);
if (number_matched == 0) return -1;
if (indef_mode == 0) {
! Is there now a single highest-scoring object?
i = SingleBestGuess();
if (i >= 0) {
#Ifdef DEBUG;
if (parser_trace >= 4) print " Single best-scoring object returned.]^";
#Endif; ! DEBUG
return i;
}
}
if (indef_mode == 1 && indef_type & PLURAL_BIT ~= 0) {
if (context ~= MULTI_TOKEN or MULTIHELD_TOKEN or MULTIEXCEPT_TOKEN
or MULTIINSIDE_TOKEN) {
etype = MULTI_PE;
return -1;
}
i = 0; offset = multiple_object-->0;
for (j=BestGuess(): j~=-1 && i<indef_wanted && i+offset<MATCH_LIST_WORDS-1:
j=BestGuess()) {
flag = 0;
BeginActivity(DECIDING_WHETHER_ALL_INC_ACT, j);
if ((ForActivity(DECIDING_WHETHER_ALL_INC_ACT, j)) == 0) {
if (j hasnt concealed && j hasnt worn) flag = 1;
if (context == MULTIHELD_TOKEN or MULTIEXCEPT_TOKEN && parent(j) ~= actor)
flag = 0;
if (action_to_be == ##Take or ##Remove && parent(j) == actor)
flag = 0;
k = ChooseObjects(j, flag);
if (k == 1)
flag = 1;
else {
if (k == 2) flag = 0;
}
} else {
flag = 0; if (RulebookSucceeded()) flag = 1;
}
EndActivity(DECIDING_WHETHER_ALL_INC_ACT, j);
if (flag == 1) {
i++; multiple_object-->(i+offset) = j;
#Ifdef DEBUG;
if (parser_trace >= 4) print " Accepting it^";
#Endif; ! DEBUG
}
else {
i = i;
#Ifdef DEBUG;
if (parser_trace >= 4) print " Rejecting it^";
#Endif; ! DEBUG
}
}
if (i < indef_wanted && indef_wanted < INDEF_ALL_WANTED) {
etype = TOOFEW_PE; multi_wanted = indef_wanted;
if (parser_trace >= 4) print "Too few found^";
multi_had=i;
return -1;
}
multiple_object-->0 = i+offset;
multi_context = context;
#Ifdef DEBUG;
if (parser_trace >= 4)
print " Made multiple object of size ", i, "]^";
#Endif; ! DEBUG
return 1;
}
for (i=0 : i<number_matched : i++) match_classes-->i = 0;
n = 1;
for (i=0 : i<number_matched : i++)
if (match_classes-->i == 0) {
match_classes-->i = n++; flag = 0;
for (j=i+1 : j<number_matched : j++)
if (match_classes-->j == 0 && Identical(match_list-->i, match_list-->j) == 1) {
flag=1;
match_classes-->j = match_classes-->i;
}
if (flag == 1) match_classes-->i = 1-n;
}
n--; number_of_classes = n;
#Ifdef DEBUG;
if (parser_trace >= 4) {
print " Grouped into ", n, " possibilities by name:^";
for (i=0 : i<number_matched : i++)
if (match_classes-->i > 0)
print " ", (The) match_list-->i, " (", match_list-->i, ") --- group ",
match_classes-->i, "^";
}
#Endif; ! DEBUG
if (indef_mode == 0) {
if (n > 1) {
k = -1;
for (i=0 : i<number_matched : i++) {
if (match_scores-->i > k) {
k = match_scores-->i;
j = match_classes-->i; j = j*j;
flag = 0;
}
else
if (match_scores-->i == k) {
if ((match_classes-->i) * (match_classes-->i) ~= j)
flag = 1;
}
}
if (flag) {
#Ifdef DEBUG;
if (parser_trace >= 4) print " Unable to choose best group, so ask player.]^";
#Endif; ! DEBUG
return 0;
}
#Ifdef DEBUG;
if (parser_trace >= 4) print " Best choices are all from the same group.^";
#Endif; ! DEBUG
}
}
! When the player is really vague, or there's a single collection of
! indistinguishable objects to choose from, choose the one the player
! most recently acquired, or if the player has none of them, then
! the one most recently put where it is.
if (n == 1) dont_infer = true;
return BestGuess();
]; ! Adjudicate
-) instead of "Adjudicate" in "Parser.i6t".
Place is a room.
A locked container called a chest is in Place. A fabulous jewel is in the chest.
A brass key is in Place.
The player carries an iron key.
To decide whether the current action requires a carried noun: (- NeedToCarryNoun() -).
To decide whether the current action requires a carried second noun: (- NeedToCarrySecondNoun() -).
Whomping it with is an action applying to two things. Understand “whomp [something] with [something preferably held]” as whomping it with. [does not generate implicit take because lacking "carried thing"?]
Smacking it with is an action applying to one thing and one carried thing. Understand “smack [something] with [something]” as smacking it with. [generates implicit take even without preferably held"]
Before whomping something with something:
if the current action requires a carried noun begin;
say "CARRIED NOUN FOR WHOMPING!";
otherwise;
say "UNCARRIED NOUN FOR WHOMPING!";
end if;
if the current action requires a carried second noun begin;
say "CARRIED SECOND NOUN FOR WHOMPING!";
otherwise;
say "UNCARRIED SECOND NOUN FOR WHOMPING!";
end if.
Before smacking something with something:
if the current action requires a carried noun begin;
say "CARRIED NOUN FOR SMACKING!";
otherwise;
say "UNCARRIED NOUN FOR SMACKING!";
end if;
if the current action requires a carried second noun begin;
say "CARRIED SECOND NOUN FOR SMACKING!";
otherwise;
say "UNCARRIED SECOND NOUN FOR SMACKING!";
end if.
To smack is a verb. To whomp is a verb.
Report smacking something with something: say "[We] [smack] [the noun] with [the second noun].".
Report whomping something with something: say "[We] [whomp] [the noun] with [the second noun].".
Test me with "trace 4 / whomp chest with key / drop key / whomp chest with key / take brass key / whomp chest with key / drop key / smack chest with key / take brass key / smack chest with key / trace 0".
With “[something preferably held]”, held items get an extra 1000 points while with “a carried thing” it’s only 20 points. It also seems like with “[something preferably held]”, the carrying is optional but with “a carried thing” it’s required.
Dropping, inserting it into, putting it on are the best examples where “[something preferably held]” would be preferable over “a carried thing”, otherwise you could end up taking something just to drop it back on the floor where it was, insert it back into the container it was in or put it back into the supporter it was on.
Hope this helps.