X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2Fmain%2Fnvm%2Fagent.lisp;h=e20efa20fcbd4f39233e14572cc311244b944de4;hb=04d5397;hp=ee1d97136ad72593b48c51fa2db6e1f47babbb04;hpb=97c390f3cee5094fa6795acd4b25b7598d5dd1bd;p=clnl diff --git a/src/main/nvm/agent.lisp b/src/main/nvm/agent.lisp index ee1d971..e20efa2 100644 --- a/src/main/nvm/agent.lisp +++ b/src/main/nvm/agent.lisp @@ -38,6 +38,12 @@ DESCRIPTION: ; Don't want the setter for :who (defmethod agent-value-inner ((turtle turtle) (var (eql :who))) (turtle-who turtle)) +(defmethod agent-value-inner ((turtle turtle) (var (eql :pcolor))) + (patch-color (patch-at (turtle-xcor turtle) (turtle-ycor turtle)))) + +(defmethod set-agent-value-inner ((turtle turtle) (var (eql :pcolor)) new-val) + (setf (patch-color (patch-at (turtle-xcor turtle) (turtle-ycor turtle))) new-val)) + (defagent-value patch :pcolor patch-color) (defagent-value turtle :color) @@ -54,3 +60,13 @@ DESCRIPTION: (if (getf (turtle-own-vars turtle) var) (setf (getf (turtle-own-vars turtle) var) new-val) (setf (turtle-own-vars turtle) (append (list var new-val) (turtle-own-vars turtle))))) + +(defmethod agent-value-inner ((patch patch) var) + (when (not (find var *patches-own-vars*)) (error "~S is not a patch variable" var)) + (or (getf (patch-own-vars patch) var) 0d0)) + +(defmethod set-agent-value-inner ((patch patch) var new-val) + (when (not (find var *patches-own-vars*)) (error "~S is not a patch variable" var)) + (if (getf (patch-own-vars patch) var) + (setf (getf (patch-own-vars patch) var) new-val) + (setf (patch-own-vars patch) (append (list var new-val) (patch-own-vars patch)))))