DavidGriffith / inform6lib

The Inform6 interactive fiction standard library (moved to https://gitlab.com/DavidGriffith/inform6lib)
Other
22 stars 9 forks source link

The indef plural code in Adjudicate differs from the 6/11 version. #37

Closed DavidGriffith closed 8 years ago

DavidGriffith commented 8 years ago

From Vince at http://www.intfiction.org/forum/viewtopic.php?f=7&t=19868&start=40#p108572

Here's 6/11:

for (j=BestGuess() : j~=-1 && i<indef_wanted && i+offset<63 : j=BestGuess()) {
    flag = 0;
    if (j hasnt concealed && j hasnt worn) flag = 1;

Here's 6/12:

for (j=BestGuess() : j~=-1 && i<indef_wanted && i+offset<63 : j=BestGuess()) {
    flag = 1;
    if (j has concealed && j has worn) flag = 0;

In both cases, the meaning of the flag variable is the same. flag == 1 means accept an object, and flag == 0 means reject it.

In 6/11 the flag is initialized to 0 (reject), and various tests set it to accept object j if it's a good choice in context. In 6/12, the flag is initialized to 1 (accept) and various tests clear it to reject object j if it's not a good choice.

In 6/11, we see that j is provisionally accepted if it's not concealed and it's not worn. This makes sense in the context of commands like TAKE ALL (where we wouldn't want to include concealed objects) or DROP ALL (where we wouldn't want to drop things that the actor is wearing), and the excerpt from the DM4 that we quoted above is consistent with this: "mark each as accept unless (i) it has worn or concealed".

In 6/12, because the default value of the flag was reversed, this test also had to be reversed. Instead of accepting if j isn't concealed and isn't worn, we want to reject j if it is concealed or is worn. However, the code, as written, rejects it only if it's both concealed and worn. This is a bug.

The code should read:

if (j has concealed or worn) flag = 0;
DavidGriffith commented 8 years ago

Fixed by af6c96c8b3ab976765aa60bfab099ba589648857