1/* * module * 
    2% This is simple example explorer for the maze world.
    3%
    4%
    5% monster.pl
    6% July 11, 1996
    7% John Eikenberry
    8%
    9% Dec 13, 2035
   10% Douglas Miles
   11%
   12% Declare the module name and the exported (public) predicates.
   13*/
   14
   15
   16
   17% Declare the module name and the exported (public) predicates.
   18:-swi_module(mobExplorer,[]).   19
   20:- include(prologmud(mud_header)).   21% :- register_module_type (planning).
   22
   23tCol(mobExplorer).
   24
   25vette_idea(Agent,Act,Act):-var(Act),!,dmsg(vette_idea(Agent,Act)).
   26vette_idea(_,actSit,actSit):-!.
   27vette_idea(Agent,Act,Act):-dmsg(vette_idea(Agent,Act)).
   28
   29
   30prologHybrid(mudLabelTypeProps/3).
   31
   32% :- show_pred_info(mudLabelTypeProps/3).
   33
   34
   35:- sanity(arity(mudLabelTypeProps,3)).   36
   37prologHybrid(typeHasGlyph(tCol,ftString)).
   38% mudLabelTypeProps('Px',mobExplorer,[]).
   39typeHasGlyph(mobExplorer,"Px").
   40
   41world_agent_plan(_World,Agent,ActV):-
   42   tAgent(Agent),
   43  % isa(Agent,explorer),
   44   explorer_idea(Agent,Act),
   45   vette_idea(Agent,Act,ActV).
   46
   47==> genls(tElixer,tDrinkAble).
   48
   49% Possible agent actions.
   50explorer_idea(Agent,actEat(Elixer)) :-
   51	mudHealth(Agent,Damage),
   52	Damage < 15,
   53   mudPossess(Agent,List),
   54   obj_memb(Elixer,List),
   55   isa(Elixer,tElixer).
   56
   57explorer_idea(Agent,actEat(tFood)) :-
   58	mudEnergy(Agent,Charge),
   59	Charge < 150,
   60   mudPossess(Agent,List),
   61   obj_memb(Food,List),
   62   isa(Food,tFood).
   63
   64explorer_idea(Agent,actTake(Good)) :-
   65	mudNearBody(Agent,What),
   66        obj_memb(Good,What),
   67	isa_any(Good,[tGold,tElixer,tTreasure]).  
   68
   69explorer_idea(Agent,actTake(Good)) :-
   70	mudNearBody(Agent,What),
   71        obj_memb(Good,What),
   72	isa_any(Good,[tFood,tUsefull,tItem]).
   73
   74explorer_idea(Agent,actMove(1,Dir)) :-
   75	mudGetPrecepts(Agent,List),
   76	list_object_dir_sensed(_,List,tTreasure,Dir).
   77
   78explorer_idea(Agent,actMove(3,Dir)) :-
   79	mudGetPrecepts(Agent,List),
   80	list_object_dir_sensed(_,List,mobMonster,OppDir),
   81	reverse_dir(OppDir,Dir),
   82	number_to_dir(N,Dir,vHere),
   83        nth1(N,List,What),
   84	What == [].
   85
   86explorer_idea(Agent,actMove(1,Dir)) :-
   87	mudGetPrecepts(Agent,List),
   88	list_object_dir_sensed(_,List,tUsefull,Dir).
   89
   90explorer_idea(Agent,actMove(1,Dir)) :-
   91	mudGetPrecepts(Agent,List),
   92	list_object_dir_sensed(_,List,tAgent,Dir).
   93
   94explorer_idea(Agent,actMove(5,Dir)) :-
   95	mudMemory(Agent,aDirectionsFn([Dir|_])),
   96	number_to_dir(Num,Dir,vHere),
   97	mudNearReach(Agent,List),
   98	nth1(Num,List,What),
   99	What == [].
  100
  101explorer_idea(Agent,actAttack(Dir)) :-
  102	mudNearReach(Agent,List),
  103	list_object_dir_near(List,mobMonster,Dir).
  104
  105explorer_idea(Agent,actLook) :-
  106        req1(mudMemory(Agent,aDirectionsFn(Old))),
  107	del(mudMemory(Agent,aDirectionsFn(Old))),
  108	random_permutation(Old,New),
  109	ain(mudMemory(Agent,aDirectionsFn(New))).
  110
  111:- set_prolog_flag(runtime_debug,3).  112
  113:- include(prologmud(mud_footer)).