trinity icon indicating copy to clipboard operation
trinity copied to clipboard

When the parser infers PRSO, it does not check if PRSI is required

Open eriktorbjorn opened this issue 5 years ago • 1 comments

This is a bug I noticed back when I first played the game, and was just trying verbs at random:

>SHINE
[the splinter]

The splinter illuminates the b   rather poorly.

The SHARD-F routine assumes there is a PRSI:

	       (<VERB? POINT-AT SHINE-AT>
		<TELL CTHEO " illuminates " THEI " rather poorly." CR>
		<RTRUE>)

And judging by the syntax definition, that should be a safe assumption:

<SYNTAX SHINE OBJECT (FIND LIGHTED) (HELD CARRIED HAVE)
	AT OBJECT (ON-GROUND IN-ROOM) = V-SHINE-AT>
<SYNTAX SHINE OBJECT (FIND LIGHTED) (HELD CARRIED HAVE)
	IN OBJECT (ON-GROUND IN-ROOM) = V-SHINE-AT>
<SYNTAX SHINE OBJECT (FIND LIGHTED) (HELD CARRIED HAVE)
	ON OBJECT (ON-GROUND IN-ROOM) = V-SHINE-AT>
<SYNTAX SHINE OBJECT (FIND LIGHTED) (HELD CARRIED HAVE)
	OVER OBJECT (ON-GROUND IN-ROOM) = V-SHINE-AT>

Yet here there isn't, and that's why it's printing garbage. The "[the splinter]" message is printed by the GWIM ("Get What I Mean"?) routine, though I'm not sure who's responsible for setting the object in the first place:

	      (<AND <T? ,P-IT-OBJECT>
		    <IS? ,P-IT-OBJECT .GBIT>>
	       <TELL "[" THE ,P-IT-OBJECT ,BRACKET>
	       <RETURN ,P-IT-OBJECT>)>

The GWIM routine is called in only two places, both of them in SYNTAX-CHECK. Which seems promising:

	<COND (<AND <T? .DRIVE1>
		    <SET OBJ
			 <GWIM <GETB .DRIVE1 ,P-SFWIM1>
			       <GETB .DRIVE1 ,P-SLOC1>
			       <GETB .DRIVE1 ,P-SPREP1>>>>
	       <PUT ,P-PRSO ,P-MATCHLEN 1>
	       <PUT ,P-PRSO 1 .OBJ>
	       <SYNTAX-FOUND .DRIVE1>)
	      (<AND <T? .DRIVE2>
		    <SET OBJ
			 <GWIM <GETB .DRIVE2 ,P-SFWIM2>
			       <GETB .DRIVE2 ,P-SLOC2>
			       <GETB .DRIVE2 ,P-SPREP2>>>>
	       <PUT ,P-PRSI ,P-MATCHLEN 1>
	       <PUT ,P-PRSI 1 .OBJ>
	       <SYNTAX-FOUND .DRIVE2>)

I have a hunch that this means the game will infer PRSO or PRSI if possible, but never both at the same time. It probably decides that once it has inferred one, the syntax is now correct. Maybe.

eriktorbjorn avatar Sep 06 '20 08:09 eriktorbjorn

I don't know what the correct fix for this is, and the code seems to date back to their earliest games, but I guess it's pretty rare for games to have a syntax where the PRSO is inferred and a PRSI is still required. I'm not sure if there is any other such syntax even in Trinity, let alone in other games.

So if we can't look backwards, what about forwards? Not much luck there. Even Sherlock has similar code, though things have been renamed. Then what about Brian Moriarty's next game, Beyond Zork? Well... that one is different:

        <COND (<T? .DRIVE1>
	       <SET X <GETB .DRIVE1 ,P-SFWIM1>>
	       <SET Y <GETB .DRIVE1 ,P-SLOC1>>
	       <SET OBJ <GWIM .X .Y <GETB .DRIVE1 ,P-SPREP1>>>
	       <COND (<T? .OBJ>
		      <PUT ,P-PRSO ,P-MATCHLEN 1>
		      <PUT ,P-PRSO 1 .OBJ>
		      <SETG P-SYNTAX .DRIVE1>
		      <SETG PRSA <GETB .DRIVE1 ,P-SACTION>>
		      <RTRUE>)>)>
      ; <SET X <GETB .DRIVE1 ,P-SFWIM1>>
      ; <SET Y <GETB .DRIVE1 ,P-SLOC1>>
      ; <SET OBJ <GWIM .X .Y <GETB .DRIVE1 ,P-SPREP1>>>
      ; <COND (<AND <T? .DRIVE1>
		    <T? .OBJ>>
	       <PUT ,P-PRSO ,P-MATCHLEN 1>
	       <PUT ,P-PRSO 1 .OBJ>
	       <SETG P-SYNTAX .DRIVE1>
	       <SETG PRSA <GETB .DRIVE1 ,P-SACTION>>
	       <RTRUE>)>
      ; <SET OBJ <GWIM <GETB .DRIVE2 ,P-SFWIM2>
		       <GETB .DRIVE2 ,P-SLOC2>
		       <GETB .DRIVE2 ,P-SPREP2>>>
	<COND (<T? .DRIVE2>
	       <SET X <GETB .DRIVE2 ,P-SFWIM2>>
	       <SET Y <GETB .DRIVE2 ,P-SLOC2>>
	       <SET OBJ <GWIM .X .Y <GETB .DRIVE2 ,P-SPREP2>>>
	       <COND (<T? .OBJ>
		      <PUT ,P-PRSI ,P-MATCHLEN 1>
		      <PUT ,P-PRSI 1 .OBJ>
		      <SETG P-SYNTAX .DRIVE2>
		      <SETG PRSA <GETB .DRIVE2 ,P-SACTION>>
		      <RTRUE>)>)
	    ; (<AND <T? .DRIVE2>
		    <T? .OBJ>>
	       <PUT ,P-PRSI ,P-MATCHLEN 1>
	       <PUT ,P-PRSI 1 .OBJ>
	       <SETG P-SYNTAX .DRIVE2>
	       <SETG PRSA <GETB .DRIVE2 ,P-SACTION>>
	       <RTRUE>)
	      (<EQUAL? .VERB ,ACT?FIND ; ,ACT?WHAT>
	       <DO-IT-YOURSELF>
	       <RFALSE>)>

So maybe he noticed the error and decided to fix it for his next game, but it was never made part of the standard Infocom parser? Anyway, I don't know what the consequences would be of backporting these changes to Trinity.

eriktorbjorn avatar Sep 06 '20 08:09 eriktorbjorn