[I7 6G60] Defining whether or not something can be picked up

I’m trying to work out an NPC behaviour that allows them to pick up the things they see. So, I’ve got a question. First, here’s an example code:

[code]Living room is a room. Jane is a woman in living room. Player is Jane.

An apple is a kind of a thing.
The green apple is an apple.
The red apple is an apple.
The rotten apple is an apple.

Definition: an apple (called A) is available:
if A is carried by a person, no;
if A is in a closed container, no;
if A is in the location of May, yes;
if A can be seen by May, yes;

Cardboard box is a container. It is in living room. It is fixed in place. The green apple is in the cardboard box.
Glass cube is a container. It is in living room. It is fixed in place. It is closed. It is transparent. The red apple is in the glass cube.
The rotten apple is in the living room.

May is a woman in the living room.
Every turn:
if there is an available apple in the location of May:
let A be a random available apple;
say “Trying to take [the A]…”;
try May taking A;
say “May whistles.”;[/code]

The definition currently only applies to May. How would I go about making it apply to every person? Can I even use definitions for that? I can’t get anything like “Definition: an apple (called A) is available to a person (called P)” to work.

You could try making availability a relation, as in section 13.12. In order to implement relation you probably want a to decide whether phrase (as in section 11.17). So you’d have something like:

[code]Availability relates an apple (called item) to a person (called grabber) when the item is available to the grabber. The verb to be available to implies the availability relation.

To decide whether (item - an apple) is available to (grabber - a person):
if the item is carried by a person, no;
if the item is in a closed container, no;
if the item is in the location of the grabber, yes;
if the item can be seen by the grabber, yes;[/code]

And then you should be able to write things like “If an apple is available to [some person]” or “let A be a random apple that is available to [some person].”

Basically, adjectives defined with Definition phrases can only have one variable at a time, and to decide phrases can have as many variables as you want but can’t be used in any way other than to test whether the condition you’ve defined holds; but if you define a relation in terms of one of these conditions then you can use it in other different kinds of constructions, like the ones you want here.

(Note: it’s possible that there may be some bugs with a verb ending in “to,” so if you get those you might want to change the preposition. Also I have totally not tested this, so I may have messed up.)

Works like a charm, thanks again.