Sunday, April 21, 2019

Chapter 10. ORPHAN-MERGE: Fix What Is Broken (part 2)

10.7 Update: New changes of ORPHAN-MERGE

First changes to ORPHAN-MERGE were with Zork 1-R88. It mainly corrected the bug when a first token in a claifying response which can be a verb and an adjective is matched as a verb first. This is especially an issue when only the first 6 characters are used. For example, the command:
        BOARD BOAT
in a location with a row boat and inflatable boat in created an orphaned command because BOAT is ambiguous. If the user then enters:
        INFLAT
the original ORPHAN-MERGE processes INFLAT as “inflate”, the verb, and asks what object to inflate. However, then this new version will understand that the user meant an “inflatable” BOAT and treat INFLAT as an adjective to clarify the ambiguous BOAT. Also, ORPHAN-MERGE will understand that the input:
        INFLAT BOAT
means INFLAT is the adjective “inflatable” because the next token, BOAT, is a noun. INFLAT will then clarify the ambiguous noun. Obviously, any token that can be a verb and adjective will be treated as a verb by PARSER if there no orphan command to clarify. “ALL” and “ONE” are also considered valid adjectives for the purpose of clarification. Finally, a new global variable, P-MERGED, is set if an orphaned command is clarified and is used mainly when printing object names in PRSO/PRSI-PRINT to ensure the whole correct object name is printed and not the clarifying token.
Planetfall-R37 introduced a similar dual word type option for tokens which can be verbs and nouns. Early in the routine, the given verb was checked for this dual word type. If it could be a noun, then ORPHAN-MERGE assumed it should be treated as a noun. The start address of the subsequent noun clause was adjusted to include the previously thought verb. For example:
        IGNITE TORCH
which will result in a missing noun error (need an indirect object). If the user then types:
        FIRE
this token can be a verb or noun. but will be treated as a noun as there is an orphaned command.
HGTG introduced the ability to clarify an ambiguous adjective. In those situations, a clarifying noun is given. Previously, any noun given in the clarifying clause is ignored (if it is the same one in the orphaned command) or causes an error if its different. Now, ORPHAN-MERGE will also look for a clarifying noun if the ambiguous word is an adjective. NCLAUSE-WIN is called to complete the clarification. ONE and ALL are valid adjectives or nouns and can clarify either ambiguous nouns or adjectives. If either of these tokens follows another adjective, then they should be considered a noun and call ACLAUSE-WIN immediately with the given adjective as the clarifying token. Finally, there is a new data structure, OVTBL, which holds the VTBL from original command that was orphaned. Essentially, ORPHAN-MERGE copies back the information from OVTBL into VTBL but sets OTBL’s VTBL addr to VTBL and not OVTBL. But the OTBL information will be copied back to ITBL.
Suspect reconfirmed the number of noun clauses in the fixed orphan command by seeing if the OTBL”s IO’s start address is set. If also skipped out of ORPHAN-MERGE if it was called while there are still unprocessed commands are given where the next verb is “tell”.
AMFV changed the checking of a given verb. If it is the same as the orphaned command, then skip over checking it as a possible an adj. If the given verb does not match, then ORPHAN-MERGE will check to see if that token can also be an adj.
Bureaucracy did not include the NCLAUSE-WIN option but did allow for the entire noun clause to be used to clarify the ambiguous noun. This is done by setting the ADJ to $01 which will cause CLAUSE-COPY to insert the entire noun clause instead of just the adjective. It also blocks certain adjectives for clarifications.
The Lurking Horror introduced the assumption that if a verb is given without a noun clause, then the verb could be the clarifying token. The start of the noun clause would then be adjusted to include the verb token. Copying of OVTBL and OTBL is gone???
Sherlock did also check to see if a solo verb can be a noun. If so, then the verb table is cleared and the start and end addresses of the DO are set to include the verb token. Sherlock will adjusted the end address of the DO clause to include the entire IO clause for certain situations (<name> + TOMB or BOX + <adj/noun>).
AMFV changed the way that the clarifying input is used with orphaned commands. The main new feature is clarifying an ambiguous noun as well. ORPHAN-MERGE still begins with
  1. Check if the new input’s verb (if given) matches the one in the orphaned command or the given verb also can be an adjective. If so, set the ADJ to $01 for now.
  2. Otherwise check if the given verb can also be a noun. If so and no other nouns were given then set the start and end addresses of the direct object clause to be those around the first token (address of the first token and address of the second token). The verb # and addr to VTBl will be cleared.
After those possible scenarios are checked, the routine does the similar checking as the first gen ORPHAN-MERGE. It first checks the scenarios where a verb is given which could have different meanings.
  1. If the new verb is different than the old verb from OTBL, then return false. The new input is probably a new command.
  2. If the new verb can also be an adjective, then save it in ADJ just in case.
  3. If the new verb can also be a noun and no noun clauses are given, then set the start and end addresses of the direct object clause to point to the verb.
The routine then does a few more checks:
  1. Rechecks the verb in the new input (if it exists). If this new verb is not the same as the one in the OTBL and it cannot also be an adjective, then RFALSE (an error).
  2. If there two noun clauses are given, then it is an error (can’t offer two answers to correct an orphaned command).
The first type of orphan correction is replacing a missing noun clause. This is marked by $01 as the start address of a noun clause. The routine will check the direct object clause first and then the indirect object clause if the direct object is not missing any information. The routine cannot correct both clauses with a single command.

  1. Check that the preposition in the new input (if given) is the same as the one in the orphaned noun clause. If it is not the same, then return false.
  2. If ADJ is set (which means the verb is can also be a clarifying adjective), then set the start and end addresses of the missing noun clause in OTBL to address of the first token in the token buffer. If the ADJ is not set, then set the start and end addresses of the missing noun clause in OTBL to the ones from the direct object clause in ITBL. For a missing indirect object clause, the routine copies the start and end addresses from the direct object clause in ITBL to the indirect object clause in OTBL and sets the # of noun clauses to 2.
If neither noun clause is missing, the routine will look for a clause with an ambiguous token. In that situation, ACLAUSE has the field # for the clause with the ambiguous token whose vocabulary address is in P-ANAM. The routine will make sure there is only 1 noun clause to clarify the ambiguous token. If is no noun clauses given and any verb in the new input cannot be an adjective as well, then it will error. The routine will then walk through the tokens in the direct object clause of the new input to find the appropriate clarifying tokens for the orphaned command.  Each token will be checked:
  1. A quantity token (ALL, EVERYT, ONE) - set current token as ADJ
  2. An adjective type - set cur token as ADJ
  3. ONE (after other tokens) - call ACLAUSE-WIN with ADJ and stop looping
  4. A noun type - If it is the same as the ambiguous token, then call ACLAUSE-WIN with ADJ. Otherwise, call NCLAUSE-WIN as the noun is a clarifying token.
If END is blank (for some reason), then set # of noun clause to 1, set END to original BEG, and set BEG to 1 token block before END. Once all the checking has been done, ORPHAN-MERGE will copy the info from OVTBL back to VTBL and copy the OTBL info back to ITBL. P-MERGED is then set to indicate the orphan command is probably fixed.

10.8 Update: New ACLAUSE-WIN expands its options

Zork 1-R88 also began to use the OVTBL to hold the corresponding verb info for the ambiguous noun. This would be used to later repopulate VTBL and create a valid command with the clarified token and ambiguous noun.
HGTG began to use the CC-TBL to hold parameters needed for ACLAUSE-WIN. Theses were mainly the source and destination buffer. This allowed other buffers besides OCLAUSE to be used. The dictionary address of the clarifying adjective in INSRT was still the only passed argument.
AMFV abandoned using CC-TBL because all of the needed values could be passed as routine arguments.
Bureaucracy added an interesting twist if ACLAUSE-WIN was called with a blank INSRT. In that situation, it is set to $01 which then causes CLAUSE-COPY to insert the entire direct object clause of the recently entered clarifying command instead of a single token. Lurking Horror got rid of this function.

10.9 Update: NCLAUSE-WIN

  • Arguments: Nothing
  • Results: True
NCLAUSE-WIN is a new routine first used in HGTG that is used when players were able to clarify an ambiguous adjective. It was not always allowed after its introduction in HGTG. It always uses the direct object clause from ITBL as the source (obviously as the clarifying noun is the first any only object given in an input) and P-ACLAUSE as the destination clause in OTBL. It also adjusts the number of noun clauses if necessary. Since Trinity, newer version 4 games and all version 5 games that did allow for ambiguous nouns used a version that did not rely on CC-TBL to pass arguments to CLAUSE-COPY. This could be done with the routine call arguments now.
This new version adds several more checks:
if there are no noun clauses and the given verb can be an noun, then assume the verb is a noun actually and create a noun clause around it. Also adjust the NCN to 1. It can then continue processing it.
It also looks for “one” when checking for nouns. Typically, “one” is usually an adjective. But if it follows after another adjective, then it should be considered a noun and call ACLAUSE-WIN immediately.

10.10  Update: New version of CLAUSE-COPY

With HGTG, the destination addresses were added to P-CCTBL in those situations where CLAUSE-COPY was need to copy tokens to something other than OCLAUSE.

Word 0
Word 1
Word 2
Word 3
Element # for start address for source token buffer
Element # for end address in source token buffer
Element # for start address in destination token buffer
Element # for end address in destination token buffer
Also the tables with source and destination addresses were passed to CLAUSE-COPY along with the clarifying adjective to insert.  
LGOP checked to see if the first token to add to the OCLAUSE is the same as the clarifying token. If so, then don’t check to see if current token to copy is the ambiguous one. Just copy it to OCLAUSE. LGOP also fixed the resetting of OCLAUSE ptrs by moving all the recently added tokens to OCLAUSE to the front of OCLAUSE.
Moonmist added more changes. First, it changed the parameters in CCTBL to the address of the destination token buffer (such as OCLAUSE) in word 2. No word 3 value is needed. Second, it also checked the first token in the destination token buffer was the same as the clarifying token when the ambiguous token is found while copying tokens. If so, it would skip over adding this clarifying token but would add the ambiguous token to the destination token. Finally, if the INSRT=$01, it would copy the entire direct object clause in the clarifying command before the ambiguous token. This allows a phrase to be copied instead of a signal token.
Bureaucracy did not have rely on CC-TBL for arguments as it was written in ZIP 4 which allowed up to 7 arguments to be passed to routines. CLAUSE-COPY past the address to the source and destination input tables, elements for the start and end addresses for the tokens to copy, source of the tokens, and the INSRT clarifying token if necessary as arguments. It has a more sophisticated memory management system though. If the end of the new clarified clause token buffer (OCLAUSE for direct object and IClause for indirect object) is close to the start of the clause that is going to be copied, the routine will not the clarified clause token buffer but modify the source clause by shifting over tokens to create space for the clarifying tokens to be inserted. This is to prevent an overrun of the clause token buffer into other buffers. Otherwise, it functioned very similar to the Moonmist. It did skip over moving the recently added tokens in the destination token buffer to the front of it if the source token buffer is the same as the destination token buffer. This is because they will be automatically inserted to the front of the destination token buffer.
The Lurking Horror allowed for a noun clause to be the clarifying information, not just a token as in previous versions of CLAUSE-COPY. Another argument, along with the original INSRT, to represent the start and end addresses of the tokens to insert when the ambiguous token is found.

Beyond Zork used the more simple version in Moonmist but did not need CC-TBL like Bureaucracy.

No comments:

Post a Comment