Multi-colored objects (more than one of the same property)

How would one go about making an object that has more than one match from the same property list. This should be a system where this is possible, not just a workaround for doing it ad hoc.

For example, if I have this:

Color is a kind of value. Colors are red and white. A thing has a color.
A candy cane is a kind of thing. A candy cane is red and white.

It doesn’t work. It only ends up with the last color (in this case “white”) found in the code. Is there something that can be done to make something like the following psuedo code possible?

Color is a kind of value. Colors are red and white. A thing has one or more colors.
A candy cane is a kind of thing. A candy cane is red and white.

Note that making each color it’s own property is no good, because then it wouldn’t be possible to use something like “”, which is also key to retain.

A variable can only have one value at a time. If you want to store multiple values, you need multiple variables.

I realize this. I am trying to get around this limitation. In another language, perhaps this would be an array of values, instead of a single value. I guess I can fiddle with this myself, now that I actually typed “array” it has me thinking that something like this could be a rule that repeats through a table. Each color can be a unique value then, and “” could loop through a table instead of returning one value… I didn’t think of doing it until I typed this response.

A list might be better, since tables for the most part can’t be created or destroyed. The difficulty will be in parsing.

You could also have a many-to-many relation between things and colors, and understand “” as a thing when the item described [relation] the color understood.

Well, I have this (I abandoned tables even before I read your remark to do so, as it was causing some headaches and this works anyway).

The kitchen is a room.

The player is in the kitchen.

A thing has a text called color1. A thing has a text called color2. A thing has a text called color3.
Understand the color1 property as describing a thing. Understand the color2 property as describing a thing. Understand the color3 property as describing a thing.

To say colors of (x - a thing):
	Let L be a list of texts;
	if color1 of x is not "":
		add color1 of x to L;
	if color2 of x is not "":
		add color2 of x to L;
	if color3 of x is not "":
		add color3 of x to L;
	say "[L]";

A candy cane is a kind of thing.

The color1 of a candy cane is usually "red". The color2 of a candy cane is usually "white".

The description of a candy cane is usually "A typical, but yummy, [colors of the item described] candy cane.".

1 candy cane is in the kitchen. 

Which gives the results:

kitchen
You can see a candy cane here.

>look candy cane
A typical, but yummy, red and white candy cane.

>look red
A typical, but yummy, red and white candy cane.

>look white
A typical, but yummy, red and white candy cane.

I am interested in what you proposed below though. I don’t know if using text properties like I did has any downsides, and I am curious to learn what you meant by relating multiple properties with a relation.

Something like this.

Color is a kind of value. The colors are red, white, green, and black.
Coloration relates various things to various colors. The verb to stain implies the reversed coloration relation.
The player carries a candy cane. The candy cane is stained red and white.
The player wears a hat. The hat is stained green.
Before printing the name of a thing (called the item): say "[the list of colors which stain the item]".

I was able to get this partially working, but there are a couple of things. I couldn’t get it to work without the reversed relation as you said, but that makes for some awkward wording “color stains x” rather than “x is stained color”. That’s not a huge deal though.

There are a few issues I haven’t been able to puzzle out though that are important. First, Inform says it can’t assign relations to kinds of thing. This means that I have to ad a “When” phrase and loop through all instances of a kind to apply the coloration relation. Further, it can’t apply more than one relation at a time, so each multi-colored kind has to make this loop for each color.

Last but not least, most actually, the coloration relation is not understood properly with the understand phrase I have. This makes any color, not the specific colors, match all items with any color. (Note you will need a strong disambiguation method in your build to be able to really tell, as the game will just constantly choose the hat as it stands leaving the parser to it’s own devices).

Color is a kind of value. The colors are red, white, green, and black.

Coloration relates various things to various colors. The verb to stain (it stains) implies the reversed coloration relation.

A candy cane is a kind of thing.

A hat is a kind of thing.

The kitchen is a room.

The player is in the kitchen. The player wears 1 hat.

1 candy cane is in the kitchen.

When play begins:
	now red stains every candy cane;
	now white stains every candy cane;
	now green stains every hat;
	now red stains every hat;
	
Understand "" as a thing when a color stains the item described.

Before printing the name of a thing (called the item): say "[the list of colors which stain the item] ".

I tried changing the understand line to this as a shot in the dark:

Understand "" as a thing when the color understood stains the item described.

But this causes some kind of cryptic error message about increasing powers of two in an array.

Finally, I ask if it is worth trying to solve these problems. This is a two part question, because first, is it even possible to solve these problems in this approach, and second, is relating various properties to various things not harder on performance than having multiple texts assigned to each thing? I’ve had a various to various relation bring my application to its knees before and I had to recode the entire implementation, so I try to avoid these…

Ok, now I have this fully working, but I am still worried about which way is best for performance. I I end up having a couple thousand things, each with at least one color, some with multiple, and I have quite a few colors, each with it’s own understand phrase like the below, I fear for the application getting to a point where it won’t work anymore. At the start of play it is going to have to loop through lists of objects many times and set up tons of relationships, and there are going to be lots of understand phrases. Color is not the only property, it’s just an example here.

Are my fears well-founded? It is so hard to test if this will become a problem as the application grows with real content and more other actual rules and data.

Color is a kind of value. The colors are red, bright red, white, green, and black.

Coloration relates various things to various colors. The verb to stain (it stains) implies the reversed coloration relation.

A candy cane is a kind of thing.

A hat is a kind of thing.

The kitchen is a room.

The player is in the kitchen. The player wears 1 hat.

1 candy cane is in the kitchen.

When play begins:
	now bright red stains every candy cane;
	now white stains every candy cane;
	now green stains every hat;
	now red stains every hat;
	
Understand "red" as a thing when red stains the item described.
Understand "red" or "bright" or "bright red" as a thing when bright red stains the item described.
Understand "white" as a thing when white stains the item described.	
Understand "green" as a thing when green stains the item described.	
Understand "black" as a thing when black stains the item described.		
	
Before printing the name of a thing (called the item): say "[the list of colors which stain the item] ".