#+(and :allegro :allegro-ide) (in-package :common-graphics-user) #+(and :allegro (not :allegro-ide)) (in-package :common-lisp-user) #+(or :mcl :lispworks4.2 :cmu18 :sbcl) (in-package :common-lisp-user) (defagent *agent-04* "*Agent-04*" ;;; ============================================================================== ;;; Establish control nodes that sense state... ;;; IF an enforcer is visible, THEN _eagerly_ run towards it. (defsensor 4-runto/enforcer *agent-04* (==> (and (inventory-item ?thing botpack.enforcer) (reachable ?thing yes) (location ?thing ?x ?y ?z)) (runto-location ?x ?y ?z 10))) ;;; IF agent is stationary, AND IF a target can be located, THEN turn ;;; to face the target. (defsensor 4-rotate/follow *agent-04* (==> (and (target ?target ?agent) (velocity ?agent 0.0 0.0 ?zv) (location ?target ?x ?y ?z)) (turnto-location ?x ?y ?z 1))) ;;; Classify the separation between an agent an a target as close, ;;; closeish, farish, or far. (defsensor 4-classify-separation *agent-04* (==> (and (target ?target ?agent) (location ?target ?tx ?ty ?tz) (location ?agent ?ax ?ay ?az) (func classify-separation ?ax ?ay ?tx ?ty ?return)) (separation ?agent ?target ?return))) ;;; ============================================================================== ;;; Establish control nodes that evaluate state via some computation... ;;; If a target is < 90 game units away, THEN stop pursuing target. (defdeliberator 4-close-stop *agent-04* (==> (separation ?agent ?target close) (stop-moving now))) ;;; Strafe towards the predicted future location of the target. (defdeliberator 4-predictive-strafeto *agent-04* (==> (estimated-future-location ?target (?x ?y ?z)) (strafeto-target ?x ?y ?z 1 ?target))) ;;; IF agent is far from a target, THEN determine/predict the future ;;; location of target. (defdeliberator 4-predict-location *agent-04* (==> (and (separation ?a ?t far) (and (location ?a ?lax ?lay ?laz) (location ?t ?tlx ?tly ?tlz)) (velocity ?t ?tvx ?tvy ?tvz) (func a4-predicted-location ?lax ?lay ?tlx ?tly ?tlz ?tvx ?tvy ?aimpoint)) (estimated-future-location ?t ?aimpoint))) ;;; IF the target is farish or far, AND IF health has been reduced by ;;; a shot, AND IF ammo is available, THEN shoot at the target. (defdeliberator 4-shoot-at *agent-04* (==> (and (or (separation ?a ?t closeish) (separation ?a ?t close)) (health ?a (?fn < ?health 100)) (currentammo ?a (?fn > ?ammo 0)) (location ?t ?x ?y ?z)) (shoot-location ?x ?y ?z))) ;;; IF agentand target are separated by a medium distance, THEN ;;; strafe towards the target. (defdeliberator 4-strafe/target *agent-04* (==> (and (or (separation ?a ?t closeish) (separation ?a ?t farish)) (location ?t ?x ?y ?z)) (strafeto-target ?x ?y ?z 1 ?t))) ;;; ============================================================================== ;;; Establish control nodes that initiate action... ;;; Asserts an intention to execute a runto-location action. (defeffector 4-runto-location *agent-04* :r (==> (runto-location ?x ?y ?z 10) (upload-cmd runto-location))) ;;; Asserts an intention to execute a strafeto-target action. (defeffector 4-strafeto-target *agent-04* :r (==> (strafeto-target ?x ?y ?z ?priority ?target) (upload-cmd strafeto-target))) ;;; Asserts an intention to execute a turnto-location action. (defeffector 4-turnto-location *agent-04* :r (==> (turnto-location ?x ?y ?z ?w) (upload-cmd turnto-location))) ;;; Asserts an intention to execute a shoot-location action. (defeffector 4-shoot-location *agent-04* :r (==> (shoot-location ?x ?y ?z) (upload-cmd shoot-location))) ;;; Asserts an intention to execute a stop-moving action. (defeffector 4-stop-moving *agent-04* :r (==> (stop-moving now) (upload-cmd stop-moving))) ;;; ============================================================================== ;;; Establish relationships between the control nodes... (deftopology *agent-04* :basic-agent :threshold-devices ((td1 . 1) (td2 . 1) (td3 . 1)) :simple-relays ($unnamed$0 $unnamed$1 $unnamed$10 $unnamed$11 $unnamed$12 $unnamed$13 $unnamed$14 $unnamed$15 $unnamed$16 $unnamed$17 $unnamed$18 $unnamed$19 $unnamed$2 $unnamed$20 $unnamed$3 $unnamed$4 $unnamed$5 $unnamed$6 $unnamed$7 $unnamed$8 $unnamed$9) :pseudo-states (i_start i_stop fork) :lines (((i_start :pos (fork)) (fork :pos (4-classify-separation)) (fork :pos (4-runto/enforcer)) (fork :pos (4-rotate/follow)) (4-rotate/follow :pos ($unnamed$1)) ($unnamed$1 :pos ($unnamed$12)) ($unnamed$12 :pos (td1)) (td1 :pos ($unnamed$13)) (td1 :neg (td3)) (td3 :neg (td2)) (td3 :pos ($unnamed$18)) ($unnamed$18 :pos (4-stop-moving)) (4-stop-moving :pos (i_stop)) (td2 :pos (4-runto-location)) (4-runto-location :pos (i_stop)) ($unnamed$13 :pos ($unnamed$20)) ($unnamed$20 :pos (4-turnto-location)) (4-turnto-location :pos (i_stop)) (4-runto/enforcer :pos ($unnamed$0)) ($unnamed$0 :pos ($unnamed$14)) ($unnamed$14 :pos ($unnamed$15)) ($unnamed$15 :pos ($unnamed$16)) ($unnamed$16 :pos (td2)) (4-classify-separation :pos (4-strafe/target)) (4-classify-separation :pos (4-predict-location)) (4-classify-separation :pos (4-close-stop)) (4-classify-separation :pos (4-shoot-at)) (4-shoot-at :pos ($unnamed$4)) ($unnamed$4 :pos ($unnamed$10)) ($unnamed$10 :pos ($unnamed$11)) ($unnamed$11 :pos ($unnamed$19)) ($unnamed$19 :pos (4-shoot-location)) (4-shoot-location :pos (i_stop)) (4-close-stop :pos ($unnamed$2)) ($unnamed$2 :pos ($unnamed$9)) ($unnamed$9 :pos (td3)) (4-predict-location :pos (4-predictive-strafeto)) (4-predictive-strafeto :pos ($unnamed$3)) (4-predictive-strafeto :neg (td1)) ($unnamed$3 :pos ($unnamed$8)) ($unnamed$8 :pos ($unnamed$17)) ($unnamed$17 :pos (4-strafeto-target)) (4-strafeto-target :pos (i_stop)) (4-strafe/target :pos ($unnamed$5)) ($unnamed$5 :pos ($unnamed$6)) ($unnamed$5 :neg (td1)) ($unnamed$6 :pos ($unnamed$7)) ($unnamed$7 :pos ($unnamed$17)))) :starts (i_start)) )