Accessing a list of a single property of multiple things

This attaches to each color value (as a property called mixmaster), what Inform calls a various to various relation, which is essentially a binary matrix (Boolean matrix, logical matrix), initially populated with all zeros, with x and y indices made up of all the possible colour values:

    B R O Y B G I V
  B 0 0 0 0 0 0 0 0
  R 0 0 0 0 0 0 0 0
  O 0 0 0 0 0 0 0 0
  Y 0 0 0 0 0 0 0 0
  B 0 0 0 0 0 0 0 0
  G 0 0 0 0 0 0 0 0
  I 0 0 0 0 0 0 0 0
  V 0 0 0 0 0 0 0 0

To see if in the mixmaster property of the color blue, yellow relates to green, you’d find the yellow column then cross-reference that with the green row: if the value at the intersection is a 0, it does not so relate, if a 1 it does relate, (the implication for our purposes being that blue + yellow gives green):

As after:

blue mixed with yellow is green;
mixmaster of the color blue:
    B R O Y B G I V
  B 0 0 0 0 0 0 0 0
  R 0 0 0 0 0 0 0 0
  O 0 0 0 0 0 0 0 0
  Y 0 0 0 0 0 0 0 0
  B 0 0 0 0 0 0 0 0
  G 0 0 0 1 0 0 0 0
  I 0 0 0 0 0 0 0 0
  V 0 0 0 0 0 0 0 0

It will immediately be obvious that we could in theory set up or end up ‘corrupting’ the matrix so:

blue mixed with yellow is orange;
blue mixed with yellow is violet;
blue mixed with yellow is green;

after which

mixmaster of the color blue	
    B R O Y B G I V
  B 0 0 0 0 0 0 0 0
  R 0 0 0 0 0 0 0 0
  O 0 0 0 1 0 0 0 0
  Y 0 0 0 0 0 0 0 0
  B 0 0 0 0 0 0 0 0
  G 0 0 0 1 0 0 0 0
  I 0 0 0 0 0 0 0 0
  V 0 0 0 1 0 0 0 0

in which case blue + yellow gives green, but could equally give orange or violet. Sometimes its useful for something to relate to more than one other thing, but in the current context mixing two colours can only produce one possible result, so we want to be sure that one- but no more than one- 1 appears in each column of the matrix, corresponding to the color produced by mixing the color holding that mixmaster property with the color of the column heading.

So-

to (c1 - color) mixed with (c2 - color) is (c3 - color):
[first clear out any existing relations in the relevant columns (i.e. set the columns all to 0), so we can't end up with more than one 1 in a column]
	repeat with c running through colors:
		now the mixmaster of c1 does not relate c2 to c;
		now the mixmaster of c2 does not relate c1 to c;
[now make the relations, ensuring reciprocity, so that e.g. blue + red gives the same color as red + blue- by adjusting the mixmasters of both red and blue simultaneously so red has one 1 in column blue and row violet, and blue has one 1 in column red and row violet.]
	now the mixmaster of c1 relates c2 to c3;
	now the mixmaster of c2 relates c1 to c3;

Now after

blue mixed with yellow is orange;
blue mixed with yellow is violet;
blue mixed with yellow is green;
mixmaster of the color blue	
    B R O Y B G I V
  B 0 0 0 0 0 0 0 0
  R 0 0 0 0 0 0 0 0
  O 0 0 0 0 0 0 0 0
  Y 0 0 0 0 0 0 0 0
  B 0 0 0 0 0 0 0 0
  G 0 0 0 1 0 0 0 0
  I 0 0 0 0 0 0 0 0
  V 0 0 0 0 0 0 0 0

the first two phrases are each overridden in turn and, in the end, blue + yellow only gives green

1 Like