Advertisement
logicmoo

New Example in PrologMUD

Nov 25th, 2018
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 1.83 KB | None | 0 0
  1.  
  2. % Looking causes Percepts
  3. oper(Agent, look(Agent)),
  4.      [ h(in, Agent, Here),
  5.        believe(Agent, h(_, Here, _)),
  6.        Here \= Agent
  7.        ], % path(Here, There)
  8.      [ precept(Agent, h(_, Here, _)) ]).
  9.  
  10. % Return an operator after substituting Agent for Agent.
  11. oper(Agent, goto_dir(Agent, walk, ExitName),
  12.      [ h(in, Agent, Here),
  13.        believe(Agent, h(exit(ExitName), Here, _)),      
  14.        h(exit(ExitName), Here, There),                    
  15.        h(exit(ReverseExit), There, Here)),
  16.        Here \= Agent, There \= Agent, Here \= There, ReverseExit \= ExitName
  17.        ], % path(Here, There)
  18.      [ ~h(in, Agent, Here),
  19.         precept_local(Here, leaves(Agent, Here, ExitName)),
  20.         h(in, Agent, There),
  21.         precept_local(There,arrives(Agent, There, ReverseExit)),
  22.      ]).
  23.  
  24. % the World agent has a *goal that no events go unhandled
  25. oper(world, handle_events(Here),
  26.      [ precept_local(Here, Event)]              
  27.      [ ~precept_local(Here, Event),
  28.        for((h(in, Agent, Here),prop(Agent,inherited(preceptQ))),precept(Agent,Event))]).
  29.  
  30. % deducer Agents who preceive leavers from some exit believe the leaving point is an exit
  31. oper(Agent, precept(Agent, leaves(Someone, Here, ExitName)),
  32.      [ did(goto_dir(Someone, walk, ExitName)),
  33.        prop(Agent,inherited(deducer)),
  34.        h(in, Agent, Here) ],
  35.      [ believe(Agent, h(exit(ExitName), Here, _)),
  36.        believe(Agent, prop(Someone,inherited(actor)))]).
  37.  
  38. % deducer Agents who preceive arivers from some entrance believe the entry location is an exit
  39. oper(Agent, precept(Agent, arrives(Someone, Here, ExitName)),
  40.      [ did(goto_dir(Someone, walk, ExitName)),
  41.        prop(Agent,inherited(deducer)),
  42.        h(in, Agent, Here) ],
  43.      [ believe(Agent, h(exit(ExitName), Here, _)),
  44.        believe(Agent, prop(Someone,inherited(actor)))]).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement