Code Challenge: A rope

Continuing the discussion from IF system code *wars:

Challenge: Create a game with a rope that can be dragged around and tied to an object.

Requirements (mostly created by @warrigal) :

Setup: (note that for parsers, things like Portable and Tieable need not use a built-in library model).

  • Create three locations.
  • Create an object that is Portable (ie can be moved by the player) and Tieable (ie can have a rope tied to them). Ex: A suitcase, a bag, a bottle.
  • Create a rope.

Implementation

  • The rope length shall be able to span two locations at a time.
  • The entire rope shall be able to be carried and dropped.
  • The rope shall have two ends, which can be carried and dropped separately.
  • Dragging:
    • If the 1st end of the rope is carried, and the player moves to an adjacent, the 2nd end of the rope shall be left behind in the location they just left.
      • This shall apply if they move two locations–the 2nd of the rope will drag behind them into the adjacent location they just left.
      • If the player returns to the previous location, they shall see the 2nd end of the rope.
      • Picking up the entire rope shall pick up the 2nd end from the other room.
  • Tying:
    • The rope shall be able to be tied to an object. (parser commands: TIE OBJECT to ROPE // TIE ROPE to OBJECT)
      • This shall work whether holding a single end or holding the entire rope.
      • If holding the entire rope, any end shall be tied and the other end shall stay free. If holding a single end, the held end (1) shall be tied and the other end (2) shall stay free.
      • The player can carry the tied object and/or the 2nd end of the rope and drop either.
      • If the tied object is picked up or dropped, the 1st end of the rope is picked up or dropped as well.
        • Vice versa for the 1st end of the rope.
      • If the player moves while holding the object and not the 2nd end of the rope, it shall follow the aforementioned dragging behavior.
        • Vice versa for if the 2nd end of the rope is carried and not the object.
      • An object shall be able to be untied.
  • I labeled one end 1 and the other end 2, but these behaviors should work for both ends.

Suggested Test:

  1. Start in location 1 with the rope and object in it.
  2. Pick up the object.
  3. Pick up end 1 of the rope.
  4. Move to location 2.
  5. Move to location 3.
  6. Return to location 2 and see end 2 of the rope.
  7. Move to location 3.
  8. Tie end 1 to the object.
  9. Drop end 1.
  10. Move to location 2.
  11. Pick up end 2 of the rope.
  12. Move to location 1.
  13. Return to location 2 and see end 1 of the rope and the object attached to it.
  14. Untie the object from the rope.

Bonus requirements:

  • Parsers: Implicit actions such as TIE OBJECT and TIE ROPE will work as TIE ROPE TO OBJECT // TIE OBJECT TO ROPE)
  • Add an object that is Tieable but not Portable. Ex: an anchor, a mailbox.
    • The player shall be able to hold the other end of the rope or drop it.
    • While holding the rope:
      • The player shall be able to return to the original location.
      • The player shall be able to move to an adjacent location.
      • The player shall not be able to move to a further location.
  • Add another Tieable and Portable object.
    • The 2nd end of the rope may be tied to other objects.
    • The 2nd end of the rope may be tied to other objects in adjacent rooms.
    • Picking up the entire rope will pick up both objects and ends.

Open to feedback!

5 Likes

Good luck everyone. I did basically this in BOSH with an extension cord, and it’s hard, but rewarding once you get it right (did I?)

1 Like

can we see? :eyes:

Ugh. Fine.

The code (I hope all) is in two files, one which covers the plugging part (BOSH/BOSH1_v9A.materials/Extensions/Philip Riley/Plugging.i7x at main · rileypb/BOSH · GitHub) and one that covers the Extension Cord part (BOSH/BOSH1_v9A.materials/Extensions/Philip Riley/Extension Cord.i7x at main · rileypb/BOSH · GitHub), which correspond to tieability and ropeness, respectively. I don’t promise that anything is readable, though. A little bit is directly related to BOSH, but most of it is generic.

3 Likes

Hello. I have accepted the challenge and made a solution in AdvSys authoring system.

Here’s a GitHub repository with the source code and also I’ve included the transcription from the test in the ReadMe.

RopeChallenge: Rope challenge implemented in AdvSys

I used standard library for the room/items and common actions (with no modifications except the Before handler). The key solution is in Rope.adv file.

It was quite nice task to fulfill. Thanks.

2 Likes