1% <?xml version="1.0"?>
    2/*************************************************************************
    3
    4    File: actionDatabase.pl
    5    Copyright (C) 2007 
    6
    7    Programmer: Luciana Benotti
    8
    9    This file is part of Frolog, version 0.1 (October 2007).
   10
   11    Frolog is free software; you can redistribute it and/or modify
   12    it under the terms of the GNU General Public License as published by
   13    the Free Software Foundation; either version 2 of the License, or
   14    (at your option) any later version.
   15
   16    Frolog is distributed in the hope that it will be useful,
   17    but WITHOUT ANY WARRANTY; without even the implied warranty of
   18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19    GNU General Public License for more details.
   20
   21    You should have received a copy of the GNU General Public License
   22    along with Frolog; if not, write to the Free Software Foundation, Inc., 
   23    59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24
   25*************************************************************************/
   26:- module(modActionDatabase, []).   27
   28/*
   29:-swi_module(modActionDatabase,[take/3,
   30			  eat/2,
   31			  drop/3,
   32			  throw/3,
   33			  put/3,
   34			  kiss/2,
   35			  kill/3,
   36			  look/2,
   37			  standup/3,
   38			  move/4,
   39			  unlock/3,
   40			  open/2,
   41			  lock/3,
   42			  shut/2,
   43			  sitdown/3,
   44			  wear/2 
   45]).  
   46*/
   47
   48/*************************************************************************
   49
   50    Function: This is the action database of the scenario FairyTaleCastle.
   51
   52    Technical: The thematic roles of the actions are obtained from the core 
   53    features of FrameNet.
   54
   55    Wishlist: Another thing is that actions need to be primitives (I
   56    think in most of the AI literature actions are taken to be basic
   57    constructs). Modification of an action is a problem. For isa,
   58    you could have
   59
   60    Take the key with your left hand!
   61    Lock the door with your right hand!
   62    Open the door carefully!
   63    etc.
   64
   65    where the action is complex. An ad-hoc way of dealing with this is
   66    to have action schemata for all possible combinations (i.e. one
   67    for taking a key with the left hand, one for taking the key with
   68    the right hand, etc.) But this option ignores the compositional
   69    nature of instructions. And you would need an infinite number of
   70    action schemata.
   71
   72    It would be interesting to have action schemas and perhaps action
   73    modifier schemas that extend existing action schemes. So for the
   74    above example you could have an action scheme for "take X" (as you
   75    already have) and action modifier scheme for "with Y hand" and
   76    combine the two when needed.
   77
   78
   79*************************************************************************/
   80
   81% :- use_module('NLPModules/Actions/execute',[k/1,notk/1,add/1,del/1)]).
   82
   83% TODO: Design the addition and deletion of the player effects.  
   84% TODO: Translate into PKS syntax:
   85% 1. Delete the pecentage symbol
   86% 2. Check if PKS accepts variables without question mark
   87% 3. Define all the predicates, functions and constants
   88% 4. Replace the letters k by K
   89% 5. In the preconditions, replace commas by ^
   90% 6. In the effects replace commas by ;
   91
   92%-->
   93%<pks>
   94%<domain name="fairytalecastle">
   95%    <symbols>
   96%      <predicates>
   97%        takeAble/1, complete ...
   98%      </predicates>
   99%      <functions>
  100%
  101%      </functions>
  102%      <constants>
  103%        nirvana
  104%      </constants>
  105%    </symbols>
  106
  107%<actions>
  108
  109% <!-- looking: This frame concerns an Agent (a person or other intelligent being) paying close attention to something, the Something -->
  110% <action name="look">
  111%	<params>Agent,Something</params>
  112actionDef(
  113look(agent(Agent),something(Something)) , [
  114%   <preconds>
  115        k(inRegion(Agent,Something)),
  116	k(tRegion(Something)),
  117%	</preconds>
  118%	<effects>
  119	ain(contains(Something,Agent)),
  120	ain(knowsAllAbout(Agent,Something))]).
  121%	</effects>
  122%</action>
  123
  124% <!-- looking: This frame concerns an Agent (a person or other intelligent being) paying close attention to something, the Something -->
  125% <action name="look">
  126%	<params>Agent,Something</params>
  127actionDef(
  128look(agent(Agent),something(Something)) , [
  129%   <preconds>
  130	notk(inRegion(Agent,Something)),
  131	k(canSee(Agent,Something)),
  132%	</preconds>
  133%	<effects>
  134	ain(knowsAllAbout(Agent,Something))]).
  135%	</effects>
  136%</action>
  137
  138% <!-- removing: An Agent causes a Something to move away from a location, the Source -->
  139% <action name="take">
  140%	<params>Agent,Something,Source</params>
  141actionDef(
  142take(agent(Agent),something(Something),source(Source)) , [
  143%       <preconds>
  144	k(takeAble(Something)),
  145	k(canAccess(Agent,Something)),
  146	notk(possess(Agent,Something)),
  147	k(supports(Source,Something)),
  148%	</preconds>
  149%	<effects>
  150	del(supports(Source,Something)),
  151	ain(possess(Agent,Something))]).
  152%	</effects>
  153%</action>
  154
  155% <!-- taking: An Agent removes a Something from a Source so that it is in the Agent's possession -->
  156% <action name="take">
  157%	<params>Agent,Something,Source</params>
  158actionDef(
  159take(agent(Agent),something(Something),source(Source)) , [
  160%       <preconds>
  161	k(takeAble(Something)),
  162	k(canAccess(Agent,Something)),
  163	notk(possess(Agent,Something)),
  164	k(contains(Source,Something)),
  165%	</preconds>
  166%	<effects>
  167	del(contains(Source,Something)),
  168	ain(possess(Agent,Something))]).
  169%	</effects>
  170%</action>
  171
  172% <!-- unlocking:  -->
  173% <action name="unlock">
  174%	<params>Agent,Something,Instrument</params>
  175actionDef(
  176unlock(agent(Agent),something(Something),instrument(Instrument)) , [
  177%   <preconds>
  178	k(canAccess(Agent,Something)),
  179	k(locked(Something)),
  180	pk(fitsin(Instrument,Something)),
  181	k(possess(Agent,Instrument)),
  182%	</preconds>
  183%	<effects>
  184	del(locked(Something)),
  185	ain(unlocked(Something)),
  186	ain(fitsin(Instrument,Something))]).
  187%	</effects>
  188%</action>
  189
  190
  191% <!-- locking:  -->
  192% <action name="lock">
  193%	<params>Agent,Something,Instrument</params>
  194actionDef(
  195lock(agent(Agent),something(Something),instrument(Instrument)) , [
  196%   <preconds>
  197	k(canAccess(Agent,Something)),
  198	k(closed(Something)),
  199	k(unlocked(Something)),
  200	k(fitsin(Instrument,Something)),
  201	k(possess(Agent,Instrument)),
  202%	</preconds>
  203%	<effects>
  204	del(unlocked(Something)),
  205	ain(locked(Something))]).
  206%	</effects>
  207%</action>
  208
  209% <!-- closure: The Agent opens/closes the Containing-object -->
  210% <action name="open">
  211%	<params>Agent,Object</params>
  212actionDef(
  213open(agent(Agent),item(Object)) , [
  214%   <preconds>
  215	k(tOpenCloseable(Object)),
  216        k(tContainer(Object)),
  217	k(closed(Object)),
  218	k(unlocked(Object)),
  219	k(canAccess(Agent,Object)),
  220%	</preconds>
  221%	<effects>
  222	del(closed(Object)),
  223	ain(open(Object)),
  224	ain(describe(contentsFn(Object)))]).
  225%	</effects>
  226%</action>
  227
  228% <!-- closure: The Agent opens/closes the Containing-object -->
  229% <action name="shut">
  230%	<params>Agent,Object</params>
  231actionDef(
  232shut(agent(Agent),item(Object)) , [
  233%   <preconds>
  234	k(tOpenCloseable(Object)),
  235        k(tContainer(Object)),
  236	k(open(Object)),
  237	k(canAccess(Agent,Object)),
  238%	</preconds>
  239%	<effects>
  240	del(open(Object)),
  241	ain(closed(Object))]).
  242%	</effects>
  243%</action>
  244
  245% <!-- ingestion: An Ingestor consumes food, drink, or smoke (Ingestibles) 
  246% <action name="eat">
  247%	<params>Ingestor,Ingestible</params>
  248actionDef(
  249eat(ingestor(Ingestor),ingestible(Ingestible)) , [
  250%   <preconds>
  251	k(findsEdible(Ingestor,Ingestible)),
  252	notk(findsDisgusting(Ingestor,Ingestible)),
  253	k(contains(Ingestor,Ingestible)),
  254%	</preconds>
  255%	<effects>
  256	del(contains(Ingestor,Ingestible)),
  257	ain(tDeleted(Ingestible))]).
  258%	</effects>
  259%</action>
  260
  261% <!-- cause_motion: An Agent causes a Something to undergo directed motion, 
  262% the Agent has control of the Something only at the Source of motion-->
  263% <action name="drop">
  264%	<params>Agent,Something,Target</params>
  265actionDef(
  266drop(agent(Agent),something(Something),goal(Target)) , [
  267%       <preconds>
  268	k(contains(Target,Agent)),
  269	k(possess(Agent,Something)),
  270%	</preconds>
  271%	<effects>
  272	del(possess(Agent,Something)),
  273	ain(contains(Target,Something))]).
  274%	</effects>
  275%</action>
  276
  277% <!-- cause_motion: An Agent causes a Something to undergo directed motion, 
  278% the Agent has control of the Something only at the Source of motion-->
  279% <action name="throw">
  280%	<params>Agent,Something,Target</params>
  281actionDef(
  282throw(agent(Agent),something(Something),goal(Target)) , [
  283%       <preconds>
  284	k(possess(Agent,Something)),
  285	k(tThinking(Something)),
  286	k(tContainer(Target)),
  287%	</preconds>
  288%	<effects>
  289	del(possess(Agent,Something)),
  290	del(tThinking(Something)),
  291	ain(contains(Target,Something)),
  292	ain(tCorpse(Something))]).
  293%	</effects>
  294%</action>
  295
  296% <!-- placing: An Agent places a Something at a location, the Target, which is 
  297% profiled -->
  298% <action name="put">
  299%	<params>Agent,Something,Target</params>
  300actionDef(
  301put(agent(Agent),something(Something),goal(Target)) , [
  302%	<preconds>
  303	k(possess(Agent,Something)),
  304	k(tContainer(Target)),
  305	k(canAccess(Agent,Target)),
  306%	</preconds>
  307%	<effects>
  308	del(possess(Agent,Something)),
  309	ain(contains(Target,Something))]).
  310%	</effects>
  311%</action>
  312
  313% <!-- placing: An Agent places a Something at a location, the Target, which is 
  314% profiled -->
  315% <action name="put">
  316%	<params>Agent,Something,Target</params>
  317actionDef(
  318put(agent(Agent),something(Something),goal(Target)) , [
  319%	<preconds>
  320	k(possess(Agent,Something)),
  321	notk(tContainer(Target)),
  322	k(canAccess(Agent,Target)),
  323%	</preconds>
  324%	<effects>
  325	del(possess(Agent,Something)),
  326	ain(supports(Target,Something))]).
  327%	</effects>
  328%</action>
  329
  330% <!-- placing: An Agent places a Something on himself -->
  331% <action name="wear">
  332%	<params>Agent,Something</params>
  333actionDef(
  334wear(agent(Agent),something(Something)) , [
  335%	<preconds>
  336	k(possess(Agent,Something)),
  337	k(canAccess(Agent,Something)),
  338	k(wearable(Something)),
  339%	</preconds>
  340%	<effects>
  341	del(possess(Agent,Something)),
  342	ain(supports(Agent,Something))]).
  343%	</effects>
  344%</action>
  345
  346% <!-- manipulation: Touch or caress with the lips as a sign of love, affection, 
  347% or greeting. -->
  348% <action name="kiss">
  349%	<params>Agent,Entity</params>
  350actionDef(
  351kiss(agent(Agent),entity(Entity)) , [
  352%	<preconds>
  353	k(tThinking(Entity)),
  354	k(canAccess(Agent,Entity)),
  355	k(findsBeautiful(Entity,Agent)),
  356%	</preconds>
  357%	<effects>
  358	ain(happy(Entity)),
  359	ain(victorious(Agent))]).
  360%	</effects>
  361%</action>
  362
  363% <!-- manipulation: Touch or caress with the lips as a sign of love, affection, 
  364% or greeting. -->
  365% <action name="kiss">
  366%	<params>Agent,Entity</params>
  367actionDef(
  368kiss(agent(Agent),entity(Entity)) , [
  369%	<preconds>
  370	k(tThinking(Entity)),
  371	k(canAccess(Agent,Entity)),
  372	notk(findsBeautiful(Entity,Agent)),
  373%	</preconds>
  374%	<effects>
  375	ain(bored(Entity))]).
  376%	</effects>
  377%</action>
  378
  379
  380% TODO: We could define only one action kill with 3 parameters. 
  381% Replacing the concepts easytokill and notsoeasytokill with a role like
  382% kills(knife1,dragon1), for example. In order to have the default use of
  383% 'kill the frog' (with your hands) the player will start knowing that
  384% kills(hands,frog1) or sth like that. These things could be defined in the
  385% TBOX. Needs thinking. -->
  386
  387% <!-- A Killer causes the death of the Victim. -->
  388% <action name="kill">
  389%	<params>Killer,Victim</params>
  390actionDef(
  391kill(killer(Killer),victim(Victim),instrument(_Instrument)) , [
  392%	<preconds>
  393	k(tThinking(Victim)),
  394	k(easytokill(Killer,Victim)),
  395	k(canAccess(Killer,Victim)),
  396%	</preconds>
  397%	<effects>
  398	del(tThinking(Victim)),
  399	ain(tCorpse(Victim))]). % TODO Here tCorpse is verbalized but not asserted because it's not a primitive concept
  400					   % This treatment might be useful for other cases, keep it in mind.  
  401%	</effects>
  402%</action>
  403
  404% <!-- A Killer causes the death of the Victim. -->
  405% <action name="kill">
  406%	<params>Killer,Victim,Instrument</params>
  407actionDef(
  408kill(killer(Killer),victim(Victim),instrument(Instrument)) , [
  409%	<preconds>
  410	k(tThinking(Victim)),
  411	k(canAccess(Killer,Victim)),
  412        k(canAccess(Killer,Instrument)),
  413	k(weapon(Instrument)),
  414%	</preconds>
  415%	<effects>
  416	del(tThinking(Victim)),
  417	ain(tCorpse(Victim))]). % TODO Here tCorpse is verbalized but not asserted because it's not a primitive concept
  418%	</effects>
  419%</action>
  420
  421% <!-- A Protagonist changes the overall postion and posture of the body from a Source to a Target. -->
  422% <action name="move">
  423%	<params>Protagonist,Source,Target</params>
  424actionDef(
  425standup(protagonist(Protagonist),source(Source),goal(Target)) , [
  426%	<preconds>
  427	k(contains(Source,Protagonist)),
  428	k(seated(Protagonist)),
  429	k(contains(Target,Source)),
  430%	</preconds>
  431%	<effects>
  432	del(contains(Source,Protagonist)),
  433	ain(contains(Target,Protagonist))]).
  434%	</effects>
  435%</action>
  436
  437% <!-- A Protagonist changes the overall postion and posture of the body from a Source to a Target. -->
  438% <action name="move">
  439%	<params>Protagonist,Source,Target</params>
  440actionDef(
  441sitdown(protagonist(Protagonist),source(Source),goal(Target)) , [
  442%	<preconds>
  443	k(contains(Source,Protagonist)),
  444	notk(seated(Protagonist)),
  445	k(seating(Target)),
  446	k(contains(Source,Target)),
  447%	</preconds>
  448%	<effects>
  449	del(contains(Source,Protagonist)),
  450	ain(contains(Target,Protagonist))]).
  451%	</effects>
  452%</action>
  453
  454% <!-- A Protagonist changes the overall postion and posture of the body from a Source to a Target. -->
  455% <action name="move">
  456%	<params>Protagonist,Source,Target</params>
  457actionDef(
  458move(protagonist(Protagonist),exit(Exit),goal(Target),source(Source)) , [
  459%	<preconds>
  460	k(inRegion(Protagonist, Source)),
  461	% I'd like to add here k(hereroom(Room)), k(hasexit(Room,Exit))
  462	notk(seated(Protagonist)),
  463	k(hasexit(Source,Exit)),
  464	k(leadsto(Exit,Target)),
  465%	</preconds>
  466%	<effects>
  467	del(contains(Source,Protagonist)),
  468	ain(contains(Target,Protagonist)),
  469	ain(leadsto(Exit,Target)),
  470	ain(knowsAllAbout(Protagonist,Source))]).
  471%	</effects>
  472%</action>
  473
  474%</actions>
  475%</domain>