AARP-Gnosis

Example 335
★★

An Encyclopedia set which treats volumes in the same place as a single object, but can also be split up.

Suppose we have a complete Encyclopedia in our game. The player is allowed to pick up the whole set (there must not be too many volumes), but also to do things with individual volumes, and indeed to scatter these volumes all over the place. Putting a volume back in the same place as the rest of the Encyclopedia should, however, restore it to the collective. We will start out by defining general rules for collectives like this:

"AARP-Gnosis"
Fitting relates various things to one thing (called the home). The verb to fit means the fitting relation. Definition: a thing is missing if it is not part of the home of it.
A collective is a kind of thing.
Before doing something to something which is part of a collective:
   let space be the holder of the home of the noun;
   move the noun to the space.
Instead of examining a collective:
   say "[The noun] consists of [the list of things which are part of the noun]."

Now the real work begins. One reason to make this an activity is that we might easily want to override it for specific objects; for instance, the generic collecting activity here would not deal properly with collectives of clothing where some items might be worn and others not. In that case, we would want to write another, more specific "collecting" activity to handle the complexities of fashion.

Collecting something is an activity.
Every turn:
   repeat with item running through collectives:
      carry out the collecting activity with the item.
To remove (item - a thing) when empty:
   let space be the holder of the item;
   if the number of things which are part of the item is 0:
      now the item is nowhere;
   if the number of things which are part of the item is 1:
      let the last thing be a random thing which is part of the item;
      move the last thing to the space;
      now the item is nowhere.
Before collecting a thing (called the item):
   remove item when empty;
   let space be the holder of the item;
   if space is not a thing and space is not a room:
      if something (called the other space) contains at least two things which fit the item, move item to the other space;
      if a room (called the other space) contains at least two things which fit the item, move item to the other space;
      if someone (called the owner) carries at least two things which fit the item, move item to the owner.
Rule for collecting a thing (called the item):
   let space be the holder of the item;
   if space is a thing or space is a room:
      repeat with component running through things held by the space:
         if the component fits the item, now the component is part of the item;
      remove item when empty.

And now for a cheerful scenario:

The Boise Memorial Library is a room. "A concrete box of a room, roughly eight feet by fourteen, which contains all the fallout shelter has to offer by way of entertainment. Someone with a grim sense of humor has tacked a READ! literacy poster to the door, as though there were anything else to do while you await the calming of the Geiger counters." The shelf is a supporter in the Library. "A battered utility shelf stands against the south wall."
The New Idahoan Encyclopedia Set is a collective. Volume A-Aalto fits the Encyclopedia. It is part of the Set. Volume AAM-Aardvark fits the Encyclopedia. It is part of the Set. Volume Aarhus-Aaron fits the Encyclopedia. It is part of the Set. Volume AARP-Gnosis fits the Encyclopedia. It is part of the Set. Volume Gnu-Zygote fits the Encyclopedia. It is part of the Set. The Set is on the shelf.

Let's have the Encyclopedia describe itself differently depending on whether it's all in one place:

After printing the name of the Set when something missing fits the Set:
   say " (missing [a list of missing things which fit the Set])"
Before printing the name of the Set when the number of missing things which fit the set is 0:
   say "complete ".
Test me with "get aarhus-aaron / look / inventory / get aam-aardvark / look / get gnu-zygote / look / get aarp-gnosis / look / inventory / drop set / look / get set / get a-aalto / inventory".
Test me with "get aarhus-aaron / look / inventory / get aam-aardvark / look / get gnu-zygote / look / get aarp-gnosis / look / inventory / drop set / look / get set / get a-aalto / inventory".
Boise Memorial Library
A concrete box of a room, roughly eight feet by fourteen, which contains all the fallout shelter has to offer by way of entertainment. Someone with a grim sense of humor has tacked a READ! literacy poster to the door, as though there were anything else to do while you await the calming of the Geiger counters.

A battered utility shelf stands against the south wall.

On the shelf is a complete New Idahoan Encyclopedia Set.

>(Testing.)

>[1] get aarhus-aaron
Taken.

>[2] look
Boise Memorial Library
A concrete box of a room, roughly eight feet by fourteen, which contains all the fallout shelter has to offer by way of entertainment. Someone with a grim sense of humor has tacked a READ! literacy poster to the door, as though there were anything else to do while you await the calming of the Geiger counters.

A battered utility shelf stands against the south wall.

On the shelf is a New Idahoan Encyclopedia Set (missing Volume Aarhus-Aaron).

>[3] inventory
You are carrying:
Volume Aarhus-Aaron

>[4] get aam-aardvark
Taken.

>[5] look
Boise Memorial Library
A concrete box of a room, roughly eight feet by fourteen, which contains all the fallout shelter has to offer by way of entertainment. Someone with a grim sense of humor has tacked a READ! literacy poster to the door, as though there were anything else to do while you await the calming of the Geiger counters.

A battered utility shelf stands against the south wall.

On the shelf is a New Idahoan Encyclopedia Set (missing Volume AAM-Aardvark and Volume Aarhus-Aaron).

>[6] get gnu-zygote
Taken.

>[7] look
Boise Memorial Library
A concrete box of a room, roughly eight feet by fourteen, which contains all the fallout shelter has to offer by way of entertainment. Someone with a grim sense of humor has tacked a READ! literacy poster to the door, as though there were anything else to do while you await the calming of the Geiger counters.

A battered utility shelf stands against the south wall.

On the shelf is a New Idahoan Encyclopedia Set (missing Volume Gnu-Zygote, Volume AAM-Aardvark and Volume Aarhus-Aaron).

>[8] get aarp-gnosis
Taken.

>[9] look
Boise Memorial Library
A concrete box of a room, roughly eight feet by fourteen, which contains all the fallout shelter has to offer by way of entertainment. Someone with a grim sense of humor has tacked a READ! literacy poster to the door, as though there were anything else to do while you await the calming of the Geiger counters.

A battered utility shelf stands against the south wall.

On the shelf is Volume A-Aalto.

>[10] inventory
You are carrying:
a New Idahoan Encyclopedia Set (missing Volume A-Aalto)

>[11] drop set
Dropped.

>[12] look
Boise Memorial Library
A concrete box of a room, roughly eight feet by fourteen, which contains all the fallout shelter has to offer by way of entertainment. Someone with a grim sense of humor has tacked a READ! literacy poster to the door, as though there were anything else to do while you await the calming of the Geiger counters.

A battered utility shelf stands against the south wall.

On the shelf is Volume A-Aalto.

You can also see a New Idahoan Encyclopedia Set (missing Volume A-Aalto) here.

>[13] get set
Taken.

>[14] get a-aalto
Taken.

>[15] inventory
You are carrying:
a complete New Idahoan Encyclopedia Set