No rope extensions? Really?

I’ve got some rope-like objects in my WIP and so far I’ve been managing them on a case-by-case basis. But I’ve decided that maybe an extension would be better. So I went on the I7 website and looked at the extensions section titled “Physics: Substances, Ropes, Energy and Weight,” thinking that if “Ropes” were in the title of the sections, there would be some rope extensions there. But did this dope find rope? Nope!

I wonder why that is? Are the examples in the manual good enough for rope users? Are ropes unpopular? Is every rope implementation too particular? Are there rope extensions elsewhere? Or is it simply that nobody’s done the work?

I think I’m ready to get started on this if the latter is true. Does anyone want to offer input on a rope extension? Here’s how I’m starting out:

[code]A connector is a kind of thing. A connector has a number called the carrying capacity. The carrying capacity of a connector is usually 2. A connector can be leavable or draggable.

Connection relates various things to one connector. The verb to connect to (he connects to, they connect to, he connected to, it is connected to, he is connected to) implies the connection relation.

Attachment relates a thing (called the first item) to a thing (called the second item) when the first item connects to the second item or the second item connects to the first item.

The verb to be attached to implies the attachment relation.[/code]

I’m not attempting to model ropes that can be in more than one room at once, but I do already have a bunch of code that can deal with “dragging” items - things that aren’t carried, but that are attached to something carried. What do you think?

Ropes, fire, and liquids are classically hell on earth to do properly, so most people elide them, and those that don’t are pretty selective with the implementation.

If you’re going to program one, it would be kind to do it in releasable extension form, but it’s not for the faint of heart or short of beta-testers.

The trick with rope (and all of these classically painful cases) is that an extension for your set of assumptions isn’t too hard. But combining everybody’s desires into a single extension is very hard.

Still, that argues for a set of extensions. “Single-room ropes with dragging” would be good to have.

I seem to remember there were some bugs in I7’s relation-pathfinding code. Is that still true? I’m realizing how important that’s going to be to generalizing the dragging behavior.

There’s 578; fast route-finding fails with relations. And there’s this one, where the explanation is that “pathfinding isn’t implemented for dynamic relations between any types” and isn’t supposed to be, though that might not be an issue for you if you’re using relations between objects.

I gave this problem a cursory glance cause it looked juicy, and decided that I would’ve implemented a rope as a series of knots… including the default non-knot which is a straight length of rope. The wikipedia articles on knots gave all kinds of interesting knot properties, and TIE A SHEEPSHANK would be fun to enter in a game.

One (or a few) property of knots is how they behave under parallel tension vs. perpendicular tension. Some knots actually morph into different defined knots under tension in particular directional ranges. And sometimes the fastest way to tie a knot is to tie a different knot and morph it to the one wanted in that way. I even learned something about my friend’s family’s boat, in how they tie it to the dock.

Seriously, check out Wikipedia on knots. Gameplay and coding ideas just leap from the page.

Have I mentioned how much I hate relations syntax? Why doesn’t this work?

[code]Connection relates one connector to various things. The verb to connect to (he connects to, they connect to, he connected to, it is connected to, he is connecting to) implies the connection relation.

Definition: A connector (called the rope) is used up rather than free:
Let used ends be the number of things connected by the rope;
Decide on whether or not used ends is at least the carrying capacity of the rope.
[/code]

EDIT: Aha. The correct phrase was “connected to by” the rope. I was trying to bypass that whole boondoggle by defining a verb for the reversed relation, but that wasn’t working out either. Except now it is. Sheesh.

I think that would be a different sort of rope extension. My idea is for chains and tubes and other things that might not necessarily be ropes. But yes, knots are fun!

That would be an issue. I have a dynamic relation that checks whether anything enclosed by one thing is connected to anything enclosed by another thing. I would need to follow that relation in order to determine what things are dragging, and if any of them are fixed in place. But I suppose I can write my own dang pathfinding algorithm…

Oh wait, looking at the bug report it seems that I was thinking of conditional relations, not dynamic relations, which appear to be a totally different thing… um, but also not allowed.

Maybe it would make sense to define a static relation that mirrors the conditional one, and manually set all the connections before running the built-in pathfinding. Does that sound like it would be better than writing my own pathfinding routine?

Well, if your relation is relating things, I think it’s OK even if you’re changing it as it’s going along? The comments at the bug tracker confuse me, but here’s an extension from something I have that does work (I think the actual code may be entirely by Aaron Reed):

[code]A theme is a kind of thing. being lost, the wild, fear, change, cold, astronomy, what’s really important, career, marriage, and senility are themes.

Suggesting relates various themes to each other. The verb to suggest (he suggests, they suggest, he suggested, it is suggested, he is suggesting) implies the suggesting relation.

Being lost suggests fear and the wild. The wild suggests what’s really important and change. Fear suggests change and senility. Change suggests what’s really important and senility. Cold suggests the wild and astronomy. Astronomy suggests career and what’s really important. What’s really important suggests marriage and change. Senility suggests fear. Marriage suggests change.[/code]

and somewhere in the middle of a rule:

let the next idea be the next step via the suggesting relation from current idea to the dominant metaphor;

Proof of concept!

[spoiler][code]“connectors”

Volume - The Connector Kind

Book - A Connector

A connector is a kind of thing. A connector has a number called the carrying capacity. The carrying capacity of a connector is usually 2. A connector can be leavable or draggable.

Book - Relations

Part - Encompassment - Enclosure or Identity

Encompassment relates a thing (called the whole) to a thing (called the component) when the whole is the component or the whole encloses the component.

The verb to encompass (he encompasses, they encompass, he encompassed, it is encompassed, he is encompassing) implies the encompassment relation.

Part - Connection

Connection relates one connector to various things. The verb to connect to (he connects to, they connect to, he connected to, it is connected to, he is connecting to) implies the connection relation.

The verb to be connected to implies the reversed connection relation.

Definition: A connector (called the rope) is used up rather than free:
Let used ends be the number of things connected to the rope;
Decide on whether or not used ends is at least the carrying capacity of the rope.

Part - Attachment - Reversable Connection

Attachment relates a thing (called the first item) to a thing (called the second item) when the first item connects to the second item or the second item connects to the first item.

The verb to be attached to implies the attachment relation.

Part - Linkage - Indirect Attachment

Chapter - The Anchor - An Object Ceiling

To decide which thing is the anchor of (component - a thing):
let H be the not-counting-parts holder of component;
while H is a thing:
now component is H;
now H is the not-counting-parts holder of component;
decide on component;

Chapter - Whether a Connector Binds a Thing to Another Thing

To decide whether (the link - a thing) bind/binds (the prisoner - a thing) to (the chain - a thing):
unless the link is a connector, no;
Now the chain is the anchor of the chain;
unless the chain encompasses the link, no;
Now the prisoner is the anchor of the prisoner;
Repeat with the appendage running through things encompassed by the prisoner:
if the link connects to the appendage, yes;
no.

Chapter - Whether a Thing is Indirectly Attached to a Thing

To decide whether (first item - a thing) is/are indirectly attached to (second item - a thing):
Repeat with the link running through connectors:
if the link binds first item to second item, yes;
if the link binds second item to first item, yes;
no.

Chapter - The Linkage Relation

Linkage relates a thing (called the first item) to a thing (called the second item) when the first item is indirectly attached to the second item.

The verb to be linked to implies the linkage relation.

Chapter - Static Linkage - for Pathfinding

Static linkage relates various connectors to various connectors. The verb to be statically linked to implies the static linkage relation.

Volume - Verbs

Book - Connecting

Part - Grammar

Understand “to” and “onto” and “on to” and “with” as “[onto]”

Understand “tie [something] [onto] [something]” as tying it to.
Understand “attach [something] [onto] [something]” as tying it to.
Understand “connect [something] [onto] [something]” as tying it to.

Part - Action

Check inserting something into a connector (this is the convert inserting into a connector to tying rule):
try tying the second noun to the noun instead.

Check tying something that is not a connector to a connector (this is the reverse nouns when tying a non-connector to a connector rule):
try tying the second noun to the noun instead.

Check tying a used up connector to something (this is the can’t tie without a free end rule):
if the second noun is a free connector:
say “(Connecting a free end of [the second noun] to [the noun])[command clarification break]”;
Silently try tying the second noun to the noun;
otherwise:
say “[The noun] doesn’t have a free end.”;
stop the action.

Check tying a connector to something when the noun is attached to the second noun (this is the can’t make two connections to one thing rule):
say “[The noun] is already attached to [the second noun]” instead;

Check tying a connector to a connector (this is the can’t connect a connector to itself rule):
if the second noun is the noun, say “There’s no need to connect [the noun] to itself.” instead;

Carry out tying a connector to something:
Now the noun connects to the second noun.

Report tying something to something:
say “You connect [the noun] to [the second noun].”;

Book - Disconnecting

Part - Grammar

Understand “from” and “out of” as “[out of]”.
Understand “off” and “off of” as “[off of]”.
Understand “from [off of]” and “[off of]” and “off [out of]” and “[out of]” as “[off out of]”.

Understand “take [something] [off out of] [something]” as removing it from.
Understand “get [something] [off out of] [something]” as removing it from.
Understand “remove [something] [off out of] [something]” as removing it from.
Understand “pull [something] [off out of] [something]” as removing it from.
[Understand “pull [things inside] [off out of] [something]” as removing it from.]

Understand the command “disconnect” as “remove”.
Understand the command “detach” as “remove”.

Does the player mean removing something from something that is attached to the noun: It is very likely.
Does the player mean removing something from something that is linked to the noun: It is likely.

Part - Action

Chapter - Removing Something From a Connector

Check removing something from a connector (This is the can’t remove from a connector rule):
say “[The noun] isn’t connected to [the second noun].” instead;

The can’t remove from a connector rule is listed first in the check removing it from rulebook.

Check removing something from something that is linked to the noun (this is the redirect removal to compound disconnecting rule):
Let first anchor be the anchor of the noun;
Let second anchor be the anchor of the second noun;
Repeat with the link running through connectors encompassed by first anchor:
repeat with component running through things encompassed by second anchor:
if the link connects to component, try disconnecting the link from component;
Repeat with the link running through connectors encompassed by second anchor:
repeat with component running through things encompassed by first anchor:
if the link connects to component, try disconnecting the link from component;
stop the action.

The redirect removal to compound disconnecting rule is listed first in the check removing it from rulebook.

Check removing something from something that is attached to the noun (this is the redirect removal to simple disconnecting rule):
Try disconnecting the noun from the second noun instead.

The redirect removal to simple disconnecting rule is listed first in the check removing it from rulebook.

Check removing a connector from something that is not a connector (this is the reverse nouns when removing a connector from a non-connector rule):
Try removing the second noun from the noun instead.

The reverse nouns when removing a connector from a non-connector rule is listed first in the check removing it from rulebook.

Chapter - The Disconnecting Action

Disconnecting it from is an action applying to two things.

Check disconnecting something from something that is not attached to the noun:
say “[The noun] isn’t attached to [the second noun].” instead.

Carry out disconnecting something from:
if the noun is a connector, now the noun does not connect to the second noun;
if the second noun is a connector, now the second noun does not connect to the noun;

Report disconnecting something from:
say “You disconnect [the noun] from [the second noun].”

Book - Dragging

To decide whether (I - an object) comes after (J - an object): (- {I} > {J} -)

To decide whether (start - a thing) is remotely linked to (end - a thing):
let loc be the location of start;
if loc is not the location of end, no;
if no connector is linked to start, no;
if no connector is linked to end, no;
Repeat with link running through connectors in loc:
Now every connector is not statically linked to link;
Repeat with link running through connectors in loc:
Repeat with second link running through connectors in loc:
if second link comes after link and second link is linked to link:
now link is statically linked to second link;
now second link is statically linked to link;
Repeat with starting link running through connectors linked to start:
Repeat with ending link running through connectors linked to end:
If the number of steps via the static linkage relation from starting link to ending link is not -1, yes;
no;

Check going when the player is linked to something:
Repeat with the shackle running through fixed in place things in the location:
if the player is remotely linked to the shackle:
say “You can’t go anywhere because you’re connected to [the shackle].” instead;

Book - Testing

Cell is a room. A rope is a connector in cell. A bolt is a fixed in place thing in cell.

Corridor is south of Cell.

The rope connects to the bolt. The rope connects to yourself.

test me with “s/disconnect rope from bolt/s”

[/code][/spoiler]

After I tried that out, I realized that pathfinding wasn’t so scary after all, since I don’t actually have to find a path. I think I’ll do it this way:

[code]A connector is a kind of thing. A connector has a number called dragging links.

Definition: A connector is dragging rather than loose if the dragging links of it is at least 1.

To calculate dragging for (the prisoner - a thing), recursing:
[Hello Dijkstra!]
Unless recursing:
Repeat with link running through connectors:
Now the dragging links of link is 0;
Let count be 0;
If the prisoner is a connector, now count is the dragging links of the prisoner;
increment count;
Repeat with link running through connectors linked to the prisoner:
if link is the prisoner, next;
if link is loose or the dragging links of link is greater than count:
Now the dragging links of link is count;
Calculate dragging for link, recursing;
[/code]