One more tiring question (about numbers)

The answers may be obvious but i’d like to be sure.

Is is better (in terms of memory, bugs avoiding and so on) to write :

A thing has a number called Number1 A thing has a number called Number2 ... ... A thing has a number called Number10

Even when you know that most of your objects won’t use these 10 numbers

Or better to write :

A dog has a number called Number1. A dog has a number called Number2. A dog has a number called Number3. A cat has a number called Number1. A horse has a number called Number1. A horse has a number called Number2. A horse has a number called Number3. A horse has a number called Number4.

?

I would say the second one. The phrase “if the [some object] supplies the [some property] property” might be useful.

A number is a property, so if you attach a series of number properties to every thing, you will use more memory than otherwise. If you are writing a small game and want to fit it into Z-machine constraints (i.e. get a .z5 or .z8 story file), this could matter, as it sounds like you would not be using many numbers for most things.

You can give properties to kinds that are more specific than “thing”, thus eliminating the need to store those properties where they’re not applicable. To use your examples:

[code]A thing has a number called Number1.

An animal has a number called Number2. An animal has a number called Number3.

A horse is a kind of animal. A horse has a number called Number4.

Field is a room. A wagon is in Field. An animal called a dog is in Field. A horse called Nelly is in Field.
[/code]

Then you would find that the wagon, dog, and horse all have a Number1 property; the dog and horse have Number2 and Number3 properties but not the wagon; and only the horse has a Number4 property.

For your own sanity, you would probably also want to give the properties names specific to their use, so:

[code]A thing has a number called weight. [Number1]

An animal has a number called ferocity. [Number2] An animal has a number called speed. [Number3]

A horse is a kind of animal. A horse has a number called load capacity. [Number4]

Field is a room. A wagon is in Field. An animal called a dog is in Field. A horse called Nelly is in Field.[/code]

Default values for a number property will be zero unless you say otherwise, e.g.:

The ferocity of an animal is usually 4.

Besides the memory savings, approach two (or, more probably approach three, applying these properties to subkinds of thing as Otis suggests) has the advantage of the story complaining if your code uses a number that it wasn’t supposed to. While nobody likes getting runtime errors, they’re much nicer than the story marching on into head-scratching behavior.

I was about to say that if you use the first approach, you won’t get a runtime error if you put a value in the wrong place – the game will just continue silently. You’ll have to decide which you want. :slight_smile:

A minor note: I think the correct syntax is:

If <something> provides the property <property name>...

And thank you very much, Draconis, for mentioning this ability to check for provided properties. It is not very well-documented (Ex 46 and WWI 26.3 seem to be about it), and I was looking for a way to do this in I7 but had given up the search. Your post convinced me that it was worth it to keep digging.