Vectors

I have been trying to get Inform understand vectors, but no luck. Not terribly important, because I’ll probably use another system anyway; but not understanding things irritates me.

One thing that I don’t get is this:

[code]A coordinate is a kind of value. (1,1,1) specifies a coordinate with parts x-coordinate, y-coordinate and z-coordinate.

A room has a coordinate. Entrance Hall is a room. The coordinate of Entrance Hall is (0,0,1).

Every turn:
say 5 times the coordinate of the location.[/code]
One would expect the every turn rule to print (0,0,5). Instead, it prints (1,0,1) – and if that looks like a binary representation of 5 to you, you’re right, as testing with other numbers will show. Why on earth is this happening? Why has Inform ditched base 10?

And why can’t I add vectors together? I would expect (0,0,3) + (2,0,1) to evaluate to (2,0,4), but instead, it gives me a syntax error. Why can I multiply coordinates with a scalar, but not add them together?

I did read through Chapter 14 of the manual, but I can’t seem to find an answer to my questions. And searching the manual for “vector” just brought up a very complicated example about mixing liquids, which did not in fact seem to define any vectors.

inform7.com/learn/man/doc233.html

For parts after the first one you must specify the maximum of each part. So (9,9,9) should work fine.

Okay… but why would the maximum of my x-coordinate (say) be 9, or any other number for that matter? I’d like to to be infinite. I don’t want to specify a maximum, and I don’t see why Inform would want to force me to do so?

Edit 1
Actually, I’m starting to think that these values work completely differently from what I imagined. Is Inform assuming that my three numbers are somehow one number written down in a weird notation?

Edit 2
Hm, I see. These things are meant to build non-standard representations of single numbers, not to build vectors. Fair enough. But I still don’t understand why you cannot add them together!

Yes exactly. You have 16 bits to share between the three parts, which gives you up to 32 for each part. With Glulx you get to share 32 bits, which gives you 1024 for each part. If you need more than this you’ll need to use lists.

I’m not sure why adding them doesn’t work.

Adding them works fine, although you get strange effects if you surpass the maximum of any part (it “carries over” into the next bigger part). The problem you had with trying to add them originally was that (0,0,3) was an invalid vector: the maximum for the last part was 1, not 3. Try it again with “(30,30,30) specifies a coordinate” and it will work.

You can add them… as long as you don’t use parenthesis anywhere. Apparently the normal parsing eats parenthesis rather than saving them for the Unit.

[code]“test” by Ron Newcomb

A coordinate is a kind of value. 99,99,99 specifies a coordinate with parts x-coordinate, y-coordinate and z-coordinate.

A room has a coordinate. Entrance Hall is a room. The coordinate of Entrance Hall is 0,0,1.

Every turn:
say 5 times the coordinate of the location;
let x be a coordinate;
now x is 00,00,03;
now x is x plus 2,0,1;
say " [x]".

[/code]

Lists are really the only viable solution for coordinates, unfortunately, since in addition to the upper limit, you also have a lower limit–you can’t have negative values on the individual terms.

This is another situation in which an I7 structure that mapped to a simple array would be useful. I’m long since out of uservoice votes, or I’d make a suggestion…

–Erik