Advertisement
logicmoo

Untitled

Nov 21st, 2018
749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 5.84 KB | None | 0 0
  1.  
  2. aXiom(doing, print_(Agent, Msg)) -->
  3.   h(descended, Agent, Here),
  4.   queue_local_event(msg_from(Agent, Msg), [Here]).
  5.  
  6.  
  7. % ==============
  8. %  WALK WEST
  9. % ==============
  10. aXiom(_, status_msg(_Begin,_End)) --> [].
  11.  
  12. aXiom(doing, goto_dir(Agent, Walk, ExitName)) -->         % go n/s/e/w/u/d/in/out  
  13.   must_act(status_msg(vBegin,goto_dir(Agent, Walk, ExitName))),
  14.   dmust(from_loc(Agent, Here)),
  15.   dmust(h(exit(ExitName), Here, _There)),
  16.   %unless(h(exit(ExitName), Here, There), failure_msg(['Can\'t go ',ExitName,' way from', Here])),
  17.   aXiom(doing, leaving(Agent, Here, Walk, ExitName)),
  18.   must_act(status_msg(vDone,goto_dir(Agent, Walk, ExitName))).
  19.  
  20. aXiom(_, leaving(Agent, Here, Walk, ExitName)) -->
  21.   %member(At, [*, to, at, through, thru]),
  22.   h(exit(ExitName), Here, There),
  23.   aXiom(_, terminates(h(_, Agent, Here))),
  24.   queue_local_event( leaving(Agent, Here, Walk, ExitName), [Here]),
  25.    % queue_local_event( msg([cap(subj(Agent)), leaves, Here, ing(Walk), to, the, ExitName]), [Here]).
  26.   dmust(aXiom(doing, arriving(Agent, There, Walk, reverse(ExitName)))).
  27.  
  28. aXiom(_, terminates(h(Prep, Object, Here))) -->
  29.  %ignore(sg(declared(h(Prep, Object, Here)))),
  30.  undeclare(h(Prep, Object, Here)).
  31.  
  32. aXiom(_, arriving(Agent, Here, Walk, ReverseDir)) -->
  33.   queue_local_event( arriving(Agent, Here, Walk, ReverseDir), [Here]),
  34.   %sg(default_rel(PrepIn, Here)), {atom(PrepIn)},
  35.   {PrepIn = in},
  36.   % [cap(subj(Agent)), arrives, PrepIn, Here, ing(Walk), from, the, ReverseDir]
  37.   dmust(aXiom(_, initiates(h(PrepIn, Agent, Here)))),
  38.   dmust(add_look(Agent)).
  39.  
  40. aXiom(_, initiates(h(Prep, Object, Dest))) -->
  41.  declare(h(Prep, Object, Dest)).
  42.  
  43.  
  44.  
  45.  
  46. % ==============
  47. %  WALK TABLE
  48. % ==============
  49. aXiom(doing, goto_obj(Agent, Walk, Object)) -->
  50.   has_rel(At, Object),
  51.   aXiom(doing, goto_prep_obj(Agent, Walk, At, Object)).
  52.  
  53.  
  54. % ==============
  55. %  WALK ON TABLE
  56. % ==============
  57. aXiom(doing, goto_prep_obj(Agent, Walk, At, Object)) -->
  58.   touchable(Agent, Object),
  59.   has_rel(At, Object),              
  60.   from_loc(Agent, Here),
  61.   open_traverse(Object, Here),
  62.   \+ is_status(Object, open, f),
  63.   aXiom(doing, entering(Agent, Here, Walk, At, Object)).
  64.  
  65. aXiom(doing, entering(Agent, Walk, Here, At, Object)) -->
  66.   moveto(Agent, At, Object, [Here],
  67.     [subj(Agent), person(Walk, es(Walk)), At, the, Object, .]),
  68.   add_look(Agent).
  69.  
  70. % ==============
  71. %  GOTO PANTRY
  72. % ==============
  73. aXiom(doing, goto_loc(Agent, _Walk, There)) -->           % go some room
  74.   has_rel(exit(_), There),
  75.   aXiom(doing, make_true(Agent, h(in, Agent, There))).
  76.  
  77. aXiom(doing, make_true(Doer, h(in, Agent, There))) -->           % go in (adjacent) room
  78.   {Doer==Agent},
  79.   has_rel(exit(_), There),
  80.   from_loc(Agent, Here),
  81.   getprop(Agent, memories(Memory)),
  82.   agent_thought_model(Agent, ModelData, Memory),
  83.   find_path(Here, There, Route, ModelData), !,
  84.   aXiom(doing, follow_plan(Agent, goto_loc(Agent, walk, There), Route)).
  85.  
  86. aXiom(doing, follow_plan(Agent, Name, [Step|Route])) -->
  87.   aXiom(doing, follow_step(Agent, Name, Step)),
  88.   aXiom(doing, follow_plan(Agent, Name, Route)).
  89.  
  90. aXiom(doing, follow_step(Agent, Name, Step)) -->
  91.   dbug(follow_step(Agent, Name, Step)),
  92.   must_act(Step).
  93.  
  94.  
  95. %  sim(verb(args...), preconds, effects)
  96. %    Agent is substituted for Agent.
  97. %    preconds are in the implied context of a State.
  98. %  In Inform, the following are implied context:
  99. %    actor, action, noun, second
  100. %  Need:
  101. %    actor/agent, verb/action, direct-object/obj1, indirect-object/obj2,
  102. %      preposition-introducing-obj2
  103. %sim(put(Obj1, Obj2),
  104. %    (  h(descended, Thing, Agent),
  105. %      can_sense(Agent, Sense, Agent, Where),
  106. %      has_rel(Relation, Where),
  107. %      h(descended, Agent, Here)),
  108. %    moveto(Thing, Relation, Where, [Here],
  109. %      [cap(subj(Agent)), person('put the', 'puts a'),
  110. %        Thing, Relation, the, Where, '.'])).
  111. aXiom(doing, does_put(Agent, Put, Thing1, At, Thing2)) -->
  112.   from_loc(Agent, Here),
  113.   % moveto(Thing1, held_by, Recipient, [Here], [cap(subj(Agent)), person([give, Recipient, the], 'gives you a'), Thing, '.'],
  114.   moveto(Thing1, At, Thing2, [Here],
  115.     [cap(subj(Agent)), person(Put, es(Put)), Thing1, At, Thing2, '.']).
  116.  
  117. aXiom(doing, take(Agent, Thing)) -->
  118.   % [silent(subj(Agent)), person('Taken.', [cap(Doer), 'grabs the', Thing, '.'])]
  119.   required(touchable(Agent, Thing)),
  120.   aXiom(doing, does_put(Agent, take, Thing, held_by, Agent)).
  121.  
  122. aXiom(doing, drop(Agent, Thing)) -->
  123.   touchable(Agent, Thing),
  124.   h(At, Agent, Here),
  125.   % has_rel(At, Here),
  126.   aXiom(doing, does_put(Agent, drop, Thing, At, Here)).
  127.  
  128. aXiom(doing, put(Agent, Thing1, Relation, Thing2)) -->
  129.   has_rel(Relation, Thing2),
  130.   (Relation \= in ; \+ is_closed(Thing2)),
  131.   touchable(Agent, Thing2), % what if "under" an "untouchable" thing?
  132.   % OK, put it
  133.   must_act( does_put(Agent, put, Thing1, Relation, Thing2)).
  134.  
  135. aXiom(doing, give(Agent, Thing, Recipient)) -->
  136.   has_rel(held_by, Recipient),
  137.   touchable(Agent, Thing),
  138.   touchable(Recipient, Agent),
  139.   % OK, give it
  140.   must_act( does_put(Agent, give, Thing, held_by, Recipient)).
  141.  
  142. % throw ball up
  143. aXiom(doing, throw_dir(Agent, Thing, ExitName)) -->
  144.   h(AtHere, Agent, Here),
  145.   (h(exit(ExitName), Here, There) -> has_rel(AtThere, There) ; (AtHere = AtThere, Here = There)),
  146.   aXiom(doing, throwing(Agent, Thing, AtThere, There)).
  147.  
  148. % throw ball at catcher
  149. aXiom(doing, throw_at(Agent, Thing, Target)) -->
  150.   % h(At, Agent, Here),
  151.   has_rel(AtTarget, Target),
  152.   aXiom(doing, throwing(Agent, Thing, AtTarget, Target)).
  153.  
  154. % throw ball over homeplate
  155. aXiom(doing, throw_prep_obj(Agent, Thing, ONTO, Target)) -->
  156.   has_rel(ONTO, Target),
  157.   %h(At, Agent, Here),
  158.   aXiom(doing, throwing(Agent, Thing, ONTO, Target)).
  159.  
  160. % is throwing the ball...
  161. aXiom(doing, throwing(Agent, Thing, At, Target)) -->
  162.   touchable(Agent, Thing),
  163.   can_sense(Agent, see, Target),
  164.   aXiom(doing, thrown(Agent, Thing, At, Target)).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement