%% entitysobjects(Entity,EntitysAndObjects,Objects) %% entitysobjects(a,[[a,1],[a,2],[b,1]],Objects). %% Entity - the entity who has interacted with the objects to find %% EntitysAndObjects - the list of pairs of and entity and an object that entity has interacted with %% Objects - the list of objects the entity has interacted with. entitysobjects(Entity,[[Entity,Object]|EntitysAndObjects],Object1,Objects2) :- append(Objects1,[Object],Objects3), entitysbjects(Entity,EntitysAndObjects,Objects3,Objects2).