"Orphaning is the mechanism where the parser asks a question to clarify an incomplete command and the player can complete the command by typing a noun phrase at the next prompt. There are a few cases where orphaning can happen: - The command was missing a noun (like [GET]) and we couldn't fill it in using the FIND flag. In this case, the incomplete command had no noun phrase and thus no matched objects. We try to use the new noun phrase to match some objects and complete the command. If the noun phrase is ambiguous, we may orphan again. - The direct or indirect object was ambiguous, i.e. it matched multiple objects when ALL/ANY weren't specified. In this case, the incomplete command had at least one noun phrase and matched a set of objects. We use the new noun phrase as a filter to narrow down the matched set. If the set isn't narrowed down to a single object, and if ALL/ANY still isn't specified, we either orphan again (if the new noun phrase eliminated at least one candidate) or give up (if it's still just as ambiguous). The data we need to store for orphaning is: - Whether we're orphaning at all - Why we're orphaning (noun missing, or noun ambiguous) - Which noun we're trying to improve (PRSO or PRSI) - Everything about the current command (PRSA, P-V-WORD, P-PRSOS, etc.) In the future, we may also need to store something about which part of the noun phrase we're trying to improve (e.g. which YSPEC is ambiguous). So we use the top bits of a word to recall whether we're orphaning and why, and reserve the rest for future use." > > >> > > ) ( ) (ELSE >> )> >) ( )> >) ( )>)>
' '>> ;"Not an orphaning response; parse as usual" ;"We asked another question; abort parse" ;"The response didn't please us; abort parse" ;"We set P-NP-[DI]OBJ; find objects" ;"We set P-PRS[OI]S and PRS[OI]; perform command" "Checks the player's command to see if it answers our orphaning question, and tries to complete the previous command if so. Sets: PRSO PRSI P-PRSOS P-PRSIS Returns: One of the O-RES-* codes above to indicate what action was taken, if any." > >> <+ ,P-LEN 1>>>> )> " PRSI") (ELSE " PRSO")> "]" CR> ;"If we were processing an order, restore P-CONT." > ;"To fill in a missing noun phrase, just copy the new one in place." ,P-NP-IOBJ) (ELSE ,P-NP-DOBJ)>> )> ;"We're disambiguating. Loop over the previously matched objects and only keep the ones that match the new NP." ) (ELSE )> > > > > >> > ) (ELSE )>> ;"Fill in PRSO/PRSI, and swap the newly created table with P-PRSOS or P-PRSIS." >) (<1? .CNT> >) (<=? ,MCM-ANY> ;"Pick a random object" >>> ) (ELSE )> ) (ELSE )> ;"See if we solved the problem." ) ( <=? ,MCM-ALL>> ) ( ) (ELSE )>>