This brings back some old memories…
Many years ago, I and several fellow employees were writing an adventure game. ( The sysadmin liked to play them, so we were very quietly allocated lots of processor time and lots of disk space )
To manipulate objects, we used bit arrays. Each object had a number, and a corresponding location in arrays. This meant that any adjective could be treated as an array,
For example if the brass lantern was the third object, and the brass dagger was the fifth object, then the concept of ‘brass’ was represented by flipping the third and fifth bits in an array, like this: 0010100000.
( I’m using a mere 10 digits for clarity here. In practice we used 64 bits. That was enough objects for a challenging game )
A silver dagger might be the second object. Thus the word ‘dagger’ would be represented by flipping the second bit and the fifth bit ( 010010000 ).
To parse the noun portion of a sentence, we simply bitwise ANDed the appropriate arrays. IOW, when the player typed ‘brass dagger’, we pulled up the corresponding arrays for the words ‘brass’ and ‘dagger’ ( 0010100000 and 010010000 ) performed a bitwise AND operation on them ( which resulted in 000010000 ) and we had a unique index into our array of objects.
We began to slowly realize that there was no fundamental difference between nouns and adjectives. The noun ‘dagger’ was essentially an adjective that meant daggerlike objects. It was an array of bits.
This was followed by the realization that a list of objects in a particular room was also functionally the same: an array of bits noting all-the-objects-in-the-octagonal-room was functionally just another adjective.
This representation as bit arrays allows for some fast parsing and realistic conversations. If the player said GET DAGGER, we could simply AND the array for dagger with the array of objects in the current room.
If the result was an array with no bits set, we could echo I SEE NO DAGGER HERE.
If the result was an array with only one bit set, it allowed us to recognize a unique object.
If there were multiple daggers in the room, the resulting array would have more than one bit set, each bit could be used as an index to an array of objects, and it was easy to generate the question DO YOU MEAN THE BRASS DAGGER OR THE SILVER DAGGER?
When the player answered that with one word, we ANDed his reply to get an array with only one bit set which allowed us to recognize a unique object.
Another use was the ‘reasonableness’ arrays, one for each verb. IOW, every verb had a corresponding bit array of objects for which it was unreasonable to try to parse. So it was quick and easy to generate an error message like YOU CANNOT DRINK A DAGGER.
So far, this is simple, and there are no unexpected behaviors. Every reference to an object is turned into a bit array. We can parse the player’s reference to any object in the cave, and even have limited conversations about those objects.
Our success with bit arrays led us to try to represent knowledge - not in the absolute sense, but what particular characters know.
For example, the troll might know about the silver dagger but not the brass dagger. What-the-troll-knows was another adjective, represented as bits.
When the player asks the troll about daggers, the troll might reply THE BRASS DAGGER WILL NOT PIERCE DRAGON HIDE. The troll can’t say that the silver dagger can do the job, because he doesn’t know.
This naturally led to concealed knowledge, and thus to lying. There could be a bit array called what-the-troll-will-reveal. The troll might know about the silver dagger, but won’t say so.
If the player bribes the troll with a few zorkmids, this is documented in flipping a few bits in the array.
Then, when asked, the troll reveals what he knows.
We soon found out that we needed an array for what objects the player knows. Otherwise, a clever player will say LOOK FOR WAND. ( When outdoors, the verb ‘look’ cannot easily be constrained by the list of objects in the immediate room. )
A gullible parser will then ask DO YOU MEAN THE SILVER WAND OR THE BLUE WAND? This tells the player that wands do indeed exist, and what colors they are.
A better parser will have an array of bits labeled what-the-player-knows. It will reply WANDS? IVE NEVER HEARD OF THEM.
This soon leads into states of mind and associated cognitive quagmires. We tried arrays like what-the-player-wants, which was natural enough. A slight grasp of storytelling structure led us to try what-the-player-needs. That led us to inadvertently make the parser goal oriented, which, of course, was a mistake.
In summary, we learned that some knowledge can be represented in simple bit arrays, and they give surprisingly good results - as long as they are kept to simple concepts. More complicated concepts require more complicated forms of storing knowledge.