Robin & Orchid — 44 of 88

Ryan Veeder & Emily Boegheim

Release 4

Part - Bugfix Kindly Supplied by Melvin Rangasamy

[With some tweaks by Emily Boegheim.

This is to solve the bug whereby Inform 7 fails to realise that images showing different subjects are distinguishable objects.]

Include (-

Attribute photo;

-) after "Definitions.i6t".

Include (- has photo, -) when defining a photo.

Include (-

[ Identical o1 o2 p1 p2 n1 n2 d1 d2 i j flag;

if (o1 == o2) rtrue; ! This should never happen, but to be on the safe side

if (o1 == 0 || o2 == 0) rfalse; ! Similarly

if (o1 ofclass K3_direction || o2 ofclass K3_direction) rfalse; ! Saves time

! What complicates things is that o1 or o2 might have a parsing routine,

! so the parser can't know from here whether they are or aren't the same.

! If they have different parsing routines, we simply assume they're

! different. If they have the same routine (which they probably got from

! a class definition) then the decision process is as follows:

!

! the routine is called (with self being o1, not that it matters)

! with noun and second being set to o1 and o2, and action being set

! to the fake action TheSame. If it returns -1, they are found

! identical; if -2, different; and if >=0, then the usual method

! is used instead.

if (o1 has photo && o2 has photo) {

d1 = noun; d2 = second;

noun = o1; second = o2;

ProcessRulebook((+ the photograph comparison rule +));

noun = d1; second = d2;

if (RulebookSucceeded()) {

!print "Identical!^";

rtrue;

}

else if (RulebookFailed()) {

!print "Different!^";

rfalse;

}

}

if (o1.parse_name ~= 0 || o2.parse_name ~= 0) {

if (o1.parse_name ~= o2.parse_name) rfalse;

parser_action = ##TheSame; parser_one = o1; parser_two = o2;

j = wn; i = RunRoutines(o1,parse_name); wn = j;

if (i == -1) rtrue;

if (i == -2) rfalse;

}

! This is the default algorithm: do they have the same words in their

! "name" (i.e. property no. 1) properties. (Note that the following allows

! for repeated words and words in different orders.)

p1 = o1.&1; n1 = (o1.#1)/WORDSIZE;

p2 = o2.&1; n2 = (o2.#1)/WORDSIZE;

! for (i=0 : i<n1 : i++) { print (address) p1-->i, " "; } new_line;

! for (i=0 : i<n2 : i++) { print (address) p2-->i, " "; } new_line;

for (i=0 : i<n1 : i++) {

flag = 0;

for (j=0 : j<n2 : j++)

if (p1-->i == p2-->j) flag = 1;

if (flag == 0) rfalse;

}

for (j=0 : j<n2 : j++) {

flag = 0;

for (i=0 : i<n1 : i++)

if (p1-->i == p2-->j) flag = 1;

if (flag == 0) rfalse;

}

! print "Which are identical!^";

rtrue;

];

-) instead of "Identical" in "Parser.i6t".

[Ugh, this rule ended up being horribly complicated. Just look at all those confusing if/otherwise blocks. Gross.

To be clear, the grossness is my fault, not Melvin's.]

This is the photograph comparison rule:

let image one be random thing which is shown by the noun;

let image two be a random thing which is shown by the second noun;

if image one is image two:

[[check if one photo is subject-lit and the other isn't]

if the noun is subject-lit and the second noun is not subject-lit:

rule fails;

otherwise if the noun is not subject-lit and the second noun is subject-lit:

rule fails;

[check if one photo is subject-empty and the other is subject-full]

if the noun is subject-empty and the second noun is subject-full:

rule fails;

otherwise if the noun is subject-full and the second noun is subject-empty:

rule fails;] [1]

[if both are person photos, check whether the action descriptions match]

if the noun is a person photo and the second noun is a person photo:

if the action description of the noun matches the text the action description of the second noun:

rule succeeds;

otherwise:

rule fails;

otherwise:

rule succeeds;

otherwise: [image one is not image two]

rule fails.

Carry out taking inventory (this is the print advanced inventory rule):

issue library message taking inventory action number 2;

say ":[if the player holds less than two photos][line break][end if]";

list the contents of the player, with newlines, indented, including contents, giving inventory information, with extra indentation.

The print advanced inventory rule is listed instead of the print standard inventory rule in the carry out taking inventory rulebook.

[Removed to improve performance:]

[Part - Disambiguating Photos

[TODO: possibly try to come up with some kind of non-horrible rule for printing the name of non-photo things while disambiguating against photos]

Understand "actual" and "real" as a thing when the item described is not a photo.]

Note

[1]. DEL