enemy.asl

来自「Multiagent system programmed using Java 」· ASL 代码 · 共 52 行

ASL
52
字号
// Enemy Agent

/* Initial Beliefs */

myBehaviour(X) :- .random(R) & X = (3*R) mod 3.   // Behaviour to be a value between 0 and 3
myHealth(P) :- .random(R) & P = 10+(3*R). // Health to be a value between 10 and 13
myPosition(P) :- pos(P,X,Y) & pos(enemy(_),X,Y).

/* Initial goals */

!joinWorld.

/* Plans */
+!moveMe
   <- move;
      !!moveMe.

+!setBehaviour
	<- behaviour(1); // (To achieve advanced Requirement, feel free to set this; e.g. 2 = static
	!!moveMe.

+!joinWorld
   <- joinEnv;
   !!setBehaviour.
      
// Not 100% yet, but percepts are there; converting MAS to AgentSpeak:
+player(enemy(_)) : not .desire(go_to(player(_))) // Needs to take into account thresholds
   <- !go_to(player(_)).
   
+!seek(S,L) : true
   <- !reach_target(S); 
      !at(L);
      drop(S).

+!reach_target(S) : player(enemy(_))
   <- moveTowards;
      !reach_target(S).
+!reach_target(_).
   
+!go_to(R)   
   <- 
      ?pos(enemy(_),X,Y); 
      -+pos(last,X,Y); // Remember previous place
      !seek(player(_),R); // Seek player
      !at(last); // goes back and continue to check
      !!moveMe.

+!at(L) : at(L).
+!at(L) <- ?pos(L,X,Y);
           attack;
           !at(L).

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?